<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE DeriveFunctor #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Solver.Canonical</span><span class="hs-special">(</span><span>
</span><span id="line-5"></span><span>     </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier">canonicalize</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-6"></span><span>     </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#unifyDerived"><span class="hs-identifier">unifyDerived</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-7"></span><span>     </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#makeSuperClasses"><span class="hs-identifier">makeSuperClasses</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#maybeSym"><span class="hs-identifier">maybeSym</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-8"></span><span>     </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier">StopOrContinue</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier">stopWith</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier">continueWith</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-9"></span><span>     </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#solveCallStack"><span class="hs-identifier">solveCallStack</span></a></span><span>    </span><span class="hs-comment">-- For GHC.Tc.Solver</span><span>
</span><span id="line-10"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html"><span class="hs-identifier">GHC.Tc.Types.Constraint</span></a></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html"><span class="hs-identifier">GHC.Tc.Utils.Unify</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#swapOverTyVars"><span class="hs-identifier">swapOverTyVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#metaTyVarUpdateOK"><span class="hs-identifier">metaTyVarUpdateOK</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier">MetaTyVarUpdateResult</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Flatten.html"><span class="hs-identifier">GHC.Tc.Solver.Flatten</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html"><span class="hs-identifier">GHC.Tc.Solver.Monad</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.EvTerm.html"><span class="hs-identifier">GHC.Tc.Types.EvTerm</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>   </span><span class="hs-comment">-- cleverly decomposes types, good for completeness checking</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#mkTemplateLocals"><span class="hs-identifier">mkTemplateLocals</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html"><span class="hs-identifier">GHC.Core.FamInstEnv</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier">FamInstEnvs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Family.html"><span class="hs-identifier">GHC.Tc.Instance.Family</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Family.html#tcTopNormaliseNewTypeTF_maybe"><span class="hs-identifier">tcTopNormaliseNewTypeTF_maybe</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier">mkInScopeSet</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#delVarSetList"><span class="hs-identifier">delVarSetList</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier">DynFlags</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html"><span class="hs-identifier">GHC.Types.Name.Set</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html"><span class="hs-identifier">GHC.Types.Name.Reader</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.Type.html"><span class="hs-identifier">GHC.Hs.Type</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Hs.Type.html#HsIPName"><span class="hs-identifier">HsIPName</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html"><span class="hs-identifier">GHC.Data.Pair</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html"><span class="hs-identifier">GHC.Utils.Monad</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier">isJust</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#zip4"><span class="hs-identifier">zip4</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bifunctor.html#"><span class="hs-identifier">Data.Bifunctor</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Bifunctor.html#bimap"><span class="hs-identifier">bimap</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#"><span class="hs-identifier">Data.Foldable</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#traverse_"><span class="hs-identifier">traverse_</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
*                      The Canonicaliser                               *
*                                                                      *
************************************************************************

Note [Canonicalization]
~~~~~~~~~~~~~~~~~~~~~~~

Canonicalization converts a simple constraint to a canonical form. It is
unary (i.e. treats individual constraints one at a time).

Constraints originating from user-written code come into being as
CNonCanonicals. We know nothing about these constraints. So, first:

     Classify CNonCanoncal constraints, depending on whether they
     are equalities, class predicates, or other.

Then proceed depending on the shape of the constraint. Generally speaking,
each constraint gets flattened and then decomposed into one of several forms
(see type Ct in GHC.Tc.Types).

When an already-canonicalized constraint gets kicked out of the inert set,
it must be recanonicalized. But we know a bit about its shape from the
last time through, so we can skip the classification step.

-}</span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="hs-comment">-- Top-level canonicalization</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier hs-type">canonicalize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span id="canonicalize"><span class="annot"><span class="annottext">canonicalize :: Ct -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier hs-var hs-var">canonicalize</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CNonCanonical"><span class="hs-identifier hs-type">CNonCanonical</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681117001"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681117001"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;canNC&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-91"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116999"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-92"></span><span>      </span><span class="annot"><a href="GHC.Core.Predicate.html#ClassPred"><span class="hs-identifier hs-type">ClassPred</span></a></span><span> </span><span id="local-6989586621681116997"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116997"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116996"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116996"><span class="hs-identifier hs-var">tys</span></a></span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEvNC:cls&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116997"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116996"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span>                                  </span><span class="annot"><span class="annottext">CtEvidence -&gt; Class -&gt; [TcType] -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClassNC"><span class="hs-identifier hs-var">canClassNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681117001"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116997"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116996"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-94"></span><span>      </span><span class="annot"><a href="GHC.Core.Predicate.html#EqPred"><span class="hs-identifier hs-type">EqPred</span></a></span><span> </span><span id="local-6989586621681116990"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116990"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116989"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116989"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116988"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116988"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEvNC:eq&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116989"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116988"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-95"></span><span>                                  </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqNC"><span class="hs-identifier hs-var">canEqNC</span></a></span><span>    </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681117001"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116990"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116989"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116988"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-96"></span><span>      </span><span class="annot"><a href="GHC.Core.Predicate.html#IrredPred"><span class="hs-identifier hs-type">IrredPred</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEvNC:irred&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116999"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-97"></span><span>                                  </span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canIrred"><span class="hs-identifier hs-var">canIrred</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#OtherCIS"><span class="hs-identifier hs-var">OtherCIS</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681117001"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-98"></span><span>      </span><span class="annot"><a href="GHC.Core.Predicate.html#ForAllPred"><span class="hs-identifier hs-type">ForAllPred</span></a></span><span> </span><span id="local-6989586621681116981"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116981"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116980"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116980"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116979"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116979"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEvNC:forall&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116999"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span>                                   </span><span class="annot"><span class="annottext">CtEvidence
-&gt; [TcTyVar] -&gt; [TcType] -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canForAllNC"><span class="hs-identifier hs-var">canForAllNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681117001"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116981"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116980"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116979"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-100"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-101"></span><span>    </span><span id="local-6989586621681116999"><span class="annot"><span class="annottext">pred :: TcType
</span><a href="#local-6989586621681116999"><span class="hs-identifier hs-var hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681117001"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-102"></span><span>
</span><span id="line-103"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier hs-var">canonicalize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CQuantCan"><span class="hs-identifier hs-type">CQuantCan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#QCI"><span class="hs-identifier hs-type">QCI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">qci_ev :: QCInst -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#qci_ev"><span class="hs-identifier hs-var">qci_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116973"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116973"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_pend_sc :: QCInst -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#qci_pend_sc"><span class="hs-identifier hs-var">qci_pend_sc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116971"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116971"><span class="hs-identifier hs-var">pend_sc</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canForAll"><span class="hs-identifier hs-var">canForAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116973"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116971"><span class="hs-identifier hs-var">pend_sc</span></a></span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier hs-var">canonicalize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CIrredCan"><span class="hs-identifier hs-type">CIrredCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116968"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116968"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_status :: Ct -&gt; CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#cc_status"><span class="hs-identifier hs-var">cc_status</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116966"><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="#local-6989586621681116966"><span class="hs-identifier hs-var">status</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqPred"><span class="hs-identifier hs-type">EqPred</span></a></span><span> </span><span id="local-6989586621681116965"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116965"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116964"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116964"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116963"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116963"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116968"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- For insolubles (all of which are equalities, do /not/ flatten the arguments</span><span>
</span><span id="line-109"></span><span>    </span><span class="hs-comment">-- In #14350 doing so led entire-unnecessary and ridiculously large</span><span>
</span><span id="line-110"></span><span>    </span><span class="hs-comment">-- type function expansion.  Instead, canEqNC just applies</span><span>
</span><span id="line-111"></span><span>    </span><span class="hs-comment">-- the substitution to the predicate, and may do decomposition;</span><span>
</span><span id="line-112"></span><span>    </span><span class="hs-comment">--    e.g. a ~ [a], where [G] a ~ [Int], can decompose</span><span>
</span><span id="line-113"></span><span>    </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqNC"><span class="hs-identifier hs-var">canEqNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116968"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116965"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116964"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116963"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-116"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canIrred"><span class="hs-identifier hs-var">canIrred</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="#local-6989586621681116966"><span class="hs-identifier hs-var">status</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116968"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-117"></span><span>
</span><span id="line-118"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier hs-var">canonicalize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CDictCan"><span class="hs-identifier hs-type">CDictCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116961"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116961"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_class :: Ct -&gt; Class
</span><a href="GHC.Tc.Types.Constraint.html#cc_class"><span class="hs-identifier hs-var">cc_class</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116959"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116959"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-119"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: Ct -&gt; [TcType]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116957"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116957"><span class="hs-identifier hs-var">xis</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_pend_sc :: Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#cc_pend_sc"><span class="hs-identifier hs-var">cc_pend_sc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116955"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116955"><span class="hs-identifier hs-var">pend_sc</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-120"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;canClass&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-121"></span><span>    </span><span class="annot"><span class="annottext">CtEvidence -&gt; Class -&gt; [TcType] -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClass"><span class="hs-identifier hs-var">canClass</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116961"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116959"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116957"><span class="hs-identifier hs-var">xis</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116955"><span class="hs-identifier hs-var">pend_sc</span></a></span><span>
</span><span id="line-122"></span><span>
</span><span id="line-123"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier hs-var">canonicalize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CTyEqCan"><span class="hs-identifier hs-type">CTyEqCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116952"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116952"><span class="hs-identifier hs-var">ev</span></a></span></span><span>
</span><span id="line-124"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyvar :: Ct -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyvar"><span class="hs-identifier hs-var">cc_tyvar</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116950"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116950"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-125"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_rhs :: Ct -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#cc_rhs"><span class="hs-identifier hs-var">cc_rhs</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116948"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116948"><span class="hs-identifier hs-var">xi</span></a></span></span><span>
</span><span id="line-126"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_eq_rel :: Ct -&gt; EqRel
</span><a href="GHC.Tc.Types.Constraint.html#cc_eq_rel"><span class="hs-identifier hs-var">cc_eq_rel</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116946"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116946"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;canEqLeafTyVarEq&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-128"></span><span>    </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqNC"><span class="hs-identifier hs-var">canEqNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116952"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116946"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116950"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116948"><span class="hs-identifier hs-var">xi</span></a></span><span>
</span><span id="line-129"></span><span>      </span><span class="hs-comment">-- NB: Don't use canEqTyVar because that expects flattened types,</span><span>
</span><span id="line-130"></span><span>      </span><span class="hs-comment">-- and tv and xi may not be flat w.r.t. an updated inert set</span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canonicalize"><span class="hs-identifier hs-var">canonicalize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CFunEqCan"><span class="hs-identifier hs-type">CFunEqCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116943"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116943"><span class="hs-identifier hs-var">ev</span></a></span></span><span>
</span><span id="line-133"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_fun :: Ct -&gt; TyCon
</span><a href="GHC.Tc.Types.Constraint.html#cc_fun"><span class="hs-identifier hs-var">cc_fun</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116941"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116941"><span class="hs-identifier hs-var">fn</span></a></span></span><span>
</span><span id="line-134"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: Ct -&gt; [TcType]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116940"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116940"><span class="hs-identifier hs-var">xis1</span></a></span></span><span>
</span><span id="line-135"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_fsk :: Ct -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#cc_fsk"><span class="hs-identifier hs-var">cc_fsk</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116938"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116938"><span class="hs-identifier hs-var">fsk</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-136"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-# SCC</span><span> </span><span class="hs-pragma">&quot;canEqLeafFunEq&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-137"></span><span>    </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TyCon -&gt; [TcType] -&gt; TcTyVar -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canCFunEqCan"><span class="hs-identifier hs-var">canCFunEqCan</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116943"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116941"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116940"><span class="hs-identifier hs-var">xis1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116938"><span class="hs-identifier hs-var">fsk</span></a></span><span>
</span><span id="line-138"></span><span>
</span><span id="line-139"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
*                      Class Canonicalization
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canClassNC"><span class="hs-identifier hs-type">canClassNC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span class="hs-comment">-- &quot;NC&quot; means &quot;non-canonical&quot;; that is, we have got here</span><span>
</span><span id="line-149"></span><span class="hs-comment">-- from a NonCanonical constraint, not from a CDictCan</span><span>
</span><span id="line-150"></span><span class="hs-comment">-- Precondition: EvVar is class evidence</span><span>
</span><span id="line-151"></span><span id="canClassNC"><span class="annot"><span class="annottext">canClassNC :: CtEvidence -&gt; Class -&gt; [TcType] -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClassNC"><span class="hs-identifier hs-var hs-var">canClassNC</span></a></span></span><span> </span><span id="local-6989586621681116935"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116934"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116934"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116933"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116933"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-152"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isGiven"><span class="hs-identifier hs-var">isGiven</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span>  </span><span class="hs-comment">-- See Note [Eagerly expand given superclasses]</span><span>
</span><span id="line-153"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116931"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116931"><span class="hs-identifier hs-var">sc_cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; [TcTyVar] -&gt; [TcType] -&gt; Class -&gt; [TcType] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mkStrictSuperClasses"><span class="hs-identifier hs-var">mkStrictSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116934"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116933"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-154"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#emitWork"><span class="hs-identifier hs-var">emitWork</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116931"><span class="hs-identifier hs-var">sc_cts</span></a></span><span>
</span><span id="line-155"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Class -&gt; [TcType] -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClass"><span class="hs-identifier hs-var">canClass</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116934"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116933"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isWanted"><span class="hs-identifier hs-var">isWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-158"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116927"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681116927"><span class="hs-identifier hs-var">ip_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [TcType] -&gt; Maybe FastString
</span><a href="GHC.Tc.Utils.TcType.html#isCallStackPred"><span class="hs-identifier hs-var">isCallStackPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116934"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116933"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-159"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#OccurrenceOf"><span class="hs-identifier hs-type">OccurrenceOf</span></a></span><span> </span><span id="local-6989586621681116924"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681116924"><span class="hs-identifier hs-var">func</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Constraint.html#ctLocOrigin"><span class="hs-identifier hs-var">ctLocOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116922"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-160"></span><span>  </span><span class="hs-comment">-- If we're given a CallStack constraint that arose from a function</span><span>
</span><span id="line-161"></span><span>  </span><span class="hs-comment">-- call, we need to push the current call-site onto the stack instead</span><span>
</span><span id="line-162"></span><span>  </span><span class="hs-comment">-- of solving it directly from a given.</span><span>
</span><span id="line-163"></span><span>  </span><span class="hs-comment">-- See Note [Overview of implicit CallStacks] in GHC.Tc.Types.Evidence</span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-comment">-- and Note [Solving CallStack constraints] in GHC.Tc.Solver.Monad</span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- First we emit a new constraint that will capture the</span><span>
</span><span id="line-166"></span><span>         </span><span class="hs-comment">-- given CallStack.</span><span>
</span><span id="line-167"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116921"><span class="annot"><span class="annottext">new_loc :: CtLoc
</span><a href="#local-6989586621681116921"><span class="hs-identifier hs-var hs-var">new_loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; CtOrigin -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#setCtLocOrigin"><span class="hs-identifier hs-var">setCtLocOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116922"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsIPName -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#IPOccOrigin"><span class="hs-identifier hs-var">IPOccOrigin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FastString -&gt; HsIPName
</span><a href="GHC.Hs.Type.html#HsIPName"><span class="hs-identifier hs-var">HsIPName</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681116927"><span class="hs-identifier hs-var">ip_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-168"></span><span>                            </span><span class="hs-comment">-- We change the origin to IPOccOrigin so</span><span>
</span><span id="line-169"></span><span>                            </span><span class="hs-comment">-- this rule does not fire again.</span><span>
</span><span id="line-170"></span><span>                            </span><span class="hs-comment">-- See Note [Overview of implicit CallStacks]</span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116917"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116917"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; TcType -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newWantedEvVarNC"><span class="hs-identifier hs-var">newWantedEvVarNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116921"><span class="hs-identifier hs-var">new_loc</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116915"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-173"></span><span>
</span><span id="line-174"></span><span>         </span><span class="hs-comment">-- Then we solve the wanted by pushing the call-site</span><span>
</span><span id="line-175"></span><span>         </span><span class="hs-comment">-- onto the newly emitted CallStack</span><span>
</span><span id="line-176"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116914"><span class="annot"><span class="annottext">ev_cs :: EvCallStack
</span><a href="#local-6989586621681116914"><span class="hs-identifier hs-var hs-var">ev_cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RealSrcSpan -&gt; EvExpr -&gt; EvCallStack
</span><a href="GHC.Tc.Types.Evidence.html#EvCsPushCall"><span class="hs-identifier hs-var">EvCsPushCall</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681116924"><span class="hs-identifier hs-var">func</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; RealSrcSpan
</span><a href="GHC.Tc.Types.Constraint.html#ctLocSpan"><span class="hs-identifier hs-var">ctLocSpan</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116922"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; EvExpr
</span><a href="GHC.Tc.Types.Constraint.html#ctEvExpr"><span class="hs-identifier hs-var">ctEvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116917"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EvCallStack -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#solveCallStack"><span class="hs-identifier hs-var">solveCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EvCallStack
</span><a href="#local-6989586621681116914"><span class="hs-identifier hs-var">ev_cs</span></a></span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Class -&gt; [TcType] -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClass"><span class="hs-identifier hs-var">canClass</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116917"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116934"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116933"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-180"></span><span>
</span><span id="line-181"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-182"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Class -&gt; [TcType] -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClass"><span class="hs-identifier hs-var">canClass</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116934"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116933"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="#local-6989586621681116910"><span class="hs-identifier hs-var">has_scs</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116934"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-185"></span><span>    </span><span id="local-6989586621681116910"><span class="annot"><span class="annottext">has_scs :: Class -&gt; Bool
</span><a href="#local-6989586621681116910"><span class="hs-identifier hs-var hs-var">has_scs</span></a></span></span><span> </span><span id="local-6989586621681116908"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116908"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcType] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [TcType]
</span><a href="GHC.Core.Class.html#classSCTheta"><span class="hs-identifier hs-var">classSCTheta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116908"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span>    </span><span id="local-6989586621681116922"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681116922"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-187"></span><span>    </span><span id="local-6989586621681116915"><span class="annot"><span class="annottext">pred :: TcType
</span><a href="#local-6989586621681116915"><span class="hs-identifier hs-var hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116935"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#solveCallStack"><span class="hs-identifier hs-type">solveCallStack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvCallStack"><span class="hs-identifier hs-type">EvCallStack</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-190"></span><span class="hs-comment">-- Also called from GHC.Tc.Solver when defaulting call stacks</span><span>
</span><span id="line-191"></span><span id="solveCallStack"><span class="annot"><span class="annottext">solveCallStack :: CtEvidence -&gt; EvCallStack -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#solveCallStack"><span class="hs-identifier hs-var hs-var">solveCallStack</span></a></span></span><span> </span><span id="local-6989586621681116903"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116903"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116902"><span class="annot"><span class="annottext">EvCallStack
</span><a href="#local-6989586621681116902"><span class="hs-identifier hs-var">ev_cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-comment">-- We're given ev_cs :: CallStack, but the evidence term should be a</span><span>
</span><span id="line-193"></span><span>  </span><span class="hs-comment">-- dictionary, so we have to coerce ev_cs to a dictionary for</span><span>
</span><span id="line-194"></span><span>  </span><span class="hs-comment">-- `IP ip CallStack`. See Note [Overview of implicit CallStacks]</span><span>
</span><span id="line-195"></span><span>  </span><span id="local-6989586621681116901"><span class="annot"><span class="annottext">EvExpr
</span><a href="#local-6989586621681116901"><span class="hs-identifier hs-var">cs_tm</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvCallStack -&gt; TcS EvExpr
forall (m :: * -&gt; *).
(MonadThings m, HasModule m, HasDynFlags m) =&gt;
EvCallStack -&gt; m EvExpr
</span><a href="GHC.Tc.Types.EvTerm.html#evCallStack"><span class="hs-identifier hs-var">evCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">EvCallStack
</span><a href="#local-6989586621681116902"><span class="hs-identifier hs-var">ev_cs</span></a></span><span>
</span><span id="line-196"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116899"><span class="annot"><span class="annottext">ev_tm :: EvTerm
</span><a href="#local-6989586621681116899"><span class="hs-identifier hs-var hs-var">ev_tm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvExpr -&gt; TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#mkEvCast"><span class="hs-identifier hs-var">mkEvCast</span></a></span><span> </span><span class="annot"><span class="annottext">EvExpr
</span><a href="#local-6989586621681116901"><span class="hs-identifier hs-var">cs_tm</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#wrapIP"><span class="hs-identifier hs-var">wrapIP</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116903"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span>  </span><span class="annot"><span class="annottext">CtEvidence -&gt; EvTerm -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setEvBindIfWanted"><span class="hs-identifier hs-var">setEvBindIfWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116903"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681116899"><span class="hs-identifier hs-var">ev_tm</span></a></span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canClass"><span class="hs-identifier hs-type">canClass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-200"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-201"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>            </span><span class="hs-comment">-- True &lt;=&gt; un-explored superclasses</span><span>
</span><span id="line-202"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- Precondition: EvVar is class evidence</span><span>
</span><span id="line-204"></span><span>
</span><span id="line-205"></span><span id="canClass"><span class="annot"><span class="annottext">canClass :: CtEvidence -&gt; Class -&gt; [TcType] -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClass"><span class="hs-identifier hs-var hs-var">canClass</span></a></span></span><span> </span><span id="local-6989586621681116895"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116895"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116894"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116894"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116893"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116893"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span id="local-6989586621681116892"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116892"><span class="hs-identifier hs-var">pend_sc</span></a></span></span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-glyph">=</span><span>   </span><span class="hs-comment">-- all classes do *nominal* matching</span><span>
</span><span id="line-207"></span><span>    </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">ctEvRole</span><span> </span><span class="hs-identifier">ev</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">Nominal</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">ev</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cls</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-208"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116886"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116886"><span class="hs-identifier hs-var">xis</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116885"><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681116885"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116884"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116884"><span class="hs-identifier hs-var">_kind_co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TyCon -&gt; [TcType] -&gt; TcS ([TcType], [TcCoercion], TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flattenArgsNom"><span class="hs-identifier hs-var">flattenArgsNom</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116895"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116882"><span class="hs-identifier hs-var">cls_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116893"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-209"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">MASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTcReflCo</span><span> </span><span class="hs-identifier">_kind_co</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-210"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116879"><span class="annot"><span class="annottext">co :: TcCoercion
</span><a href="#local-6989586621681116879"><span class="hs-identifier hs-var hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [TcCoercion] -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcTyConAppCo"><span class="hs-identifier hs-var">mkTcTyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116882"><span class="hs-identifier hs-var">cls_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681116885"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-211"></span><span>             </span><span id="local-6989586621681116877"><span class="annot"><span class="annottext">xi :: TcType
</span><a href="#local-6989586621681116877"><span class="hs-identifier hs-var hs-var">xi</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.Predicate.html#mkClassPred"><span class="hs-identifier hs-var">mkClassPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116894"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116886"><span class="hs-identifier hs-var">xis</span></a></span><span>
</span><span id="line-212"></span><span>             </span><span id="local-6989586621681116875"><span class="annot"><span class="annottext">mk_ct :: CtEvidence -&gt; Ct
</span><a href="#local-6989586621681116875"><span class="hs-identifier hs-var hs-var">mk_ct</span></a></span></span><span> </span><span id="local-6989586621681116874"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116874"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CDictCan :: CtEvidence -&gt; Class -&gt; [TcType] -&gt; Bool -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#CDictCan"><span class="hs-identifier hs-type">CDictCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116874"><span class="hs-identifier hs-var">new_ev</span></a></span><span>
</span><span id="line-213"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: [TcType]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116886"><span class="hs-identifier hs-var">xis</span></a></span><span>
</span><span id="line-214"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_class :: Class
</span><a href="GHC.Tc.Types.Constraint.html#cc_class"><span class="hs-identifier hs-var">cc_class</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116894"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-215"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_pend_sc :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#cc_pend_sc"><span class="hs-identifier hs-var">cc_pend_sc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116892"><span class="hs-identifier hs-var">pend_sc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-216"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116873"><span class="annot"><span class="annottext">StopOrContinue CtEvidence
</span><a href="#local-6989586621681116873"><span class="hs-identifier hs-var">mb</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TcType -&gt; TcCoercion -&gt; TcS (StopOrContinue CtEvidence)
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-var">rewriteEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116895"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116877"><span class="hs-identifier hs-var">xi</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116879"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-217"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canClass&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116895"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-218"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116877"><span class="hs-identifier hs-var">xi</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">StopOrContinue CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">StopOrContinue CtEvidence
</span><a href="#local-6989586621681116873"><span class="hs-identifier hs-var">mb</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-219"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">StopOrContinue Ct -&gt; TcS (StopOrContinue Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CtEvidence -&gt; Ct)
-&gt; StopOrContinue CtEvidence -&gt; StopOrContinue Ct
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="#local-6989586621681116875"><span class="hs-identifier hs-var">mk_ct</span></a></span><span> </span><span class="annot"><span class="annottext">StopOrContinue CtEvidence
</span><a href="#local-6989586621681116873"><span class="hs-identifier hs-var">mb</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-220"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-221"></span><span>    </span><span id="local-6989586621681116882"><span class="annot"><span class="annottext">cls_tc :: TyCon
</span><a href="#local-6989586621681116882"><span class="hs-identifier hs-var hs-var">cls_tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; TyCon
</span><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier hs-var hs-var">classTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116894"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span class="hs-comment">{- Note [The superclass story]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We need to add superclass constraints for two reasons:

* For givens [G], they give us a route to proof.  E.g.
    f :: Ord a =&gt; a -&gt; Bool
    f x = x == x
  We get a Wanted (Eq a), which can only be solved from the superclass
  of the Given (Ord a).

* For wanteds [W], and deriveds [WD], [D], they may give useful
  functional dependencies.  E.g.
     class C a b | a -&gt; b where ...
     class C a b =&gt; D a b where ...
  Now a [W] constraint (D Int beta) has (C Int beta) as a superclass
  and that might tell us about beta, via C's fundeps.  We can get this
  by generating a [D] (C Int beta) constraint.  It's derived because
  we don't actually have to cough up any evidence for it; it's only there
  to generate fundep equalities.

See Note [Why adding superclasses can help].

For these reasons we want to generate superclass constraints for both
Givens and Wanteds. But:

* (Minor) they are often not needed, so generating them aggressively
  is a waste of time.

* (Major) if we want recursive superclasses, there would be an infinite
  number of them.  Here is a real-life example (#10318);

     class (Frac (Frac a) ~ Frac a,
            Fractional (Frac a),
            IntegralDomain (Frac a))
         =&gt; IntegralDomain a where
      type Frac a :: *

  Notice that IntegralDomain has an associated type Frac, and one
  of IntegralDomain's superclasses is another IntegralDomain constraint.

So here's the plan:

1. Eagerly generate superclasses for given (but not wanted)
   constraints; see Note [Eagerly expand given superclasses].
   This is done using mkStrictSuperClasses in canClassNC, when
   we take a non-canonical Given constraint and cannonicalise it.

   However stop if you encounter the same class twice.  That is,
   mkStrictSuperClasses expands eagerly, but has a conservative
   termination condition: see Note [Expanding superclasses] in GHC.Tc.Utils.TcType.

2. Solve the wanteds as usual, but do no further expansion of
   superclasses for canonical CDictCans in solveSimpleGivens or
   solveSimpleWanteds; Note [Danger of adding superclasses during solving]

   However, /do/ continue to eagerly expand superclasses for new /given/
   /non-canonical/ constraints (canClassNC does this).  As #12175
   showed, a type-family application can expand to a class constraint,
   and we want to see its superclasses for just the same reason as
   Note [Eagerly expand given superclasses].

3. If we have any remaining unsolved wanteds
        (see Note [When superclasses help] in GHC.Tc.Types.Constraint)
   try harder: take both the Givens and Wanteds, and expand
   superclasses again.  See the calls to expandSuperClasses in
   GHC.Tc.Solver.simpl_loop and solveWanteds.

   This may succeed in generating (a finite number of) extra Givens,
   and extra Deriveds. Both may help the proof.

3a An important wrinkle: only expand Givens from the current level.
   Two reasons:
      - We only want to expand it once, and that is best done at
        the level it is bound, rather than repeatedly at the leaves
        of the implication tree
      - We may be inside a type where we can't create term-level
        evidence anyway, so we can't superclass-expand, say,
        (a ~ b) to get (a ~# b).  This happened in #15290.

4. Go round to (2) again.  This loop (2,3,4) is implemented
   in GHC.Tc.Solver.simpl_loop.

The cc_pend_sc flag in a CDictCan records whether the superclasses of
this constraint have been expanded.  Specifically, in Step 3 we only
expand superclasses for constraints with cc_pend_sc set to true (i.e.
isPendingScDict holds).

Why do we do this?  Two reasons:

* To avoid repeated work, by repeatedly expanding the superclasses of
  same constraint,

* To terminate the above loop, at least in the -XNoRecursiveSuperClasses
  case.  If there are recursive superclasses we could, in principle,
  expand forever, always encountering new constraints.

When we take a CNonCanonical or CIrredCan, but end up classifying it
as a CDictCan, we set the cc_pend_sc flag to False.

Note [Superclass loops]
~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have
  class C a =&gt; D a
  class D a =&gt; C a

Then, when we expand superclasses, we'll get back to the self-same
predicate, so we have reached a fixpoint in expansion and there is no
point in fruitlessly expanding further.  This case just falls out from
our strategy.  Consider
  f :: C a =&gt; a -&gt; Bool
  f x = x==x
Then canClassNC gets the [G] d1: C a constraint, and eager emits superclasses
G] d2: D a, [G] d3: C a (psc).  (The &quot;psc&quot; means it has its sc_pend flag set.)
When processing d3 we find a match with d1 in the inert set, and we always
keep the inert item (d1) if possible: see Note [Replacement vs keeping] in
GHC.Tc.Solver.Interact.  So d3 dies a quick, happy death.

Note [Eagerly expand given superclasses]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In step (1) of Note [The superclass story], why do we eagerly expand
Given superclasses by one layer?  (By &quot;one layer&quot; we mean expand transitively
until you meet the same class again -- the conservative criterion embodied
in expandSuperClasses.  So a &quot;layer&quot; might be a whole stack of superclasses.)
We do this eagerly for Givens mainly because of some very obscure
cases like this:

   instance Bad a =&gt; Eq (T a)

   f :: (Ord (T a)) =&gt; blah
   f x = ....needs Eq (T a), Ord (T a)....

Here if we can't satisfy (Eq (T a)) from the givens we'll use the
instance declaration; but then we are stuck with (Bad a).  Sigh.
This is really a case of non-confluent proofs, but to stop our users
complaining we expand one layer in advance.

Note [Instance and Given overlap] in GHC.Tc.Solver.Interact.

We also want to do this if we have

   f :: F (T a) =&gt; blah

where
   type instance F (T a) = Ord (T a)

So we may need to do a little work on the givens to expose the
class that has the superclasses.  That's why the superclass
expansion for Givens happens in canClassNC.

This same scenario happens with quantified constraints, whose superclasses
are also eagerly expanded. Test case: typecheck/should_compile/T16502b
These are handled in canForAllNC, analogously to canClassNC.

Note [Why adding superclasses can help]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Examples of how adding superclasses can help:

    --- Example 1
        class C a b | a -&gt; b
    Suppose we want to solve
         [G] C a b
         [W] C a beta
    Then adding [D] beta~b will let us solve it.

    -- Example 2 (similar but using a type-equality superclass)
        class (F a ~ b) =&gt; C a b
    And try to sllve:
         [G] C a b
         [W] C a beta
    Follow the superclass rules to add
         [G] F a ~ b
         [D] F a ~ beta
    Now we get [D] beta ~ b, and can solve that.

    -- Example (tcfail138)
      class L a b | a -&gt; b
      class (G a, L a b) =&gt; C a b

      instance C a b' =&gt; G (Maybe a)
      instance C a b  =&gt; C (Maybe a) a
      instance L (Maybe a) a

    When solving the superclasses of the (C (Maybe a) a) instance, we get
      [G] C a b, and hance by superclasses, [G] G a, [G] L a b
      [W] G (Maybe a)
    Use the instance decl to get
      [W] C a beta
    Generate its derived superclass
      [D] L a beta.  Now using fundeps, combine with [G] L a b to get
      [D] beta ~ b
    which is what we want.

Note [Danger of adding superclasses during solving]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's a serious, but now out-dated example, from #4497:

   class Num (RealOf t) =&gt; Normed t
   type family RealOf x

Assume the generated wanted constraint is:
   [W] RealOf e ~ e
   [W] Normed e

If we were to be adding the superclasses during simplification we'd get:
   [W] RealOf e ~ e
   [W] Normed e
   [D] RealOf e ~ fuv
   [D] Num fuv
==&gt;
   e := fuv, Num fuv, Normed fuv, RealOf fuv ~ fuv

While looks exactly like our original constraint. If we add the
superclass of (Normed fuv) again we'd loop.  By adding superclasses
definitely only once, during canonicalisation, this situation can't
happen.

Mind you, now that Wanteds cannot rewrite Derived, I think this particular
situation can't happen.

Note [Nested quantified constraint superclasses]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider (typecheck/should_compile/T17202)

  class C1 a
  class (forall c. C1 c) =&gt; C2 a
  class (forall b. (b ~ F a) =&gt; C2 a) =&gt; C3 a

Elsewhere in the code, we get a [G] g1 :: C3 a. We expand its superclass
to get [G] g2 :: (forall b. (b ~ F a) =&gt; C2 a). This constraint has a
superclass, as well. But we now must be careful: we cannot just add
(forall c. C1 c) as a Given, because we need to remember g2's context.
That new constraint is Given only when forall b. (b ~ F a) is true.

It's tempting to make the new Given be (forall b. (b ~ F a) =&gt; forall c. C1 c),
but that's problematic, because it's nested, and ForAllPred is not capable
of representing a nested quantified constraint. (We could change ForAllPred
to allow this, but the solution in this Note is much more local and simpler.)

So, we swizzle it around to get (forall b c. (b ~ F a) =&gt; C1 c).

More generally, if we are expanding the superclasses of
  g0 :: forall tvs. theta =&gt; cls tys
and find a superclass constraint
  forall sc_tvs. sc_theta =&gt; sc_inner_pred
we must have a selector
  sel_id :: forall cls_tvs. cls cls_tvs -&gt; forall sc_tvs. sc_theta =&gt; sc_inner_pred
and thus build
  g_sc :: forall tvs sc_tvs. theta =&gt; sc_theta =&gt; sc_inner_pred
  g_sc = /\ tvs. /\ sc_tvs. \ theta_ids. \ sc_theta_ids.
         sel_id tys (g0 tvs theta_ids) sc_tvs sc_theta_ids

Actually, we cheat a bit by eta-reducing: note that sc_theta_ids are both the
last bound variables and the last arguments. This avoids the need to produce
the sc_theta_ids at all. So our final construction is

  g_sc = /\ tvs. /\ sc_tvs. \ theta_ids.
         sel_id tys (g0 tvs theta_ids) sc_tvs

  -}</span><span>
</span><span id="line-482"></span><span>
</span><span id="line-483"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#makeSuperClasses"><span class="hs-identifier hs-type">makeSuperClasses</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-484"></span><span class="hs-comment">-- Returns strict superclasses, transitively, see Note [The superclasses story]</span><span>
</span><span id="line-485"></span><span class="hs-comment">-- See Note [The superclass story]</span><span>
</span><span id="line-486"></span><span class="hs-comment">-- The loop-breaking here follows Note [Expanding superclasses] in GHC.Tc.Utils.TcType</span><span>
</span><span id="line-487"></span><span class="hs-comment">-- Specifically, for an incoming (C t) constraint, we return all of (C t)'s</span><span>
</span><span id="line-488"></span><span class="hs-comment">--    superclasses, up to /and including/ the first repetition of C</span><span>
</span><span id="line-489"></span><span class="hs-comment">--</span><span>
</span><span id="line-490"></span><span class="hs-comment">-- Example:  class D a =&gt; C a</span><span>
</span><span id="line-491"></span><span class="hs-comment">--           class C [a] =&gt; D a</span><span>
</span><span id="line-492"></span><span class="hs-comment">-- makeSuperClasses (C x) will return (D x, C [x])</span><span>
</span><span id="line-493"></span><span class="hs-comment">--</span><span>
</span><span id="line-494"></span><span class="hs-comment">-- NB: the incoming constraints have had their cc_pend_sc flag already</span><span>
</span><span id="line-495"></span><span class="hs-comment">--     flipped to False, by isPendingScDict, so we are /obliged/ to at</span><span>
</span><span id="line-496"></span><span class="hs-comment">--     least produce the immediate superclasses</span><span>
</span><span id="line-497"></span><span id="makeSuperClasses"><span class="annot"><span class="annottext">makeSuperClasses :: [Ct] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#makeSuperClasses"><span class="hs-identifier hs-var hs-var">makeSuperClasses</span></a></span></span><span> </span><span id="local-6989586621681116869"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116869"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcS [Ct]) -&gt; [Ct] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m [b]) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier hs-var">concatMapM</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS [Ct]
</span><a href="#local-6989586621681116867"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116869"><span class="hs-identifier hs-var">cts</span></a></span><span>
</span><span id="line-498"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-499"></span><span>    </span><span id="local-6989586621681116867"><span class="annot"><span class="annottext">go :: Ct -&gt; TcS [Ct]
</span><a href="#local-6989586621681116867"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CDictCan"><span class="hs-identifier hs-type">CDictCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116859"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116859"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_class :: Ct -&gt; Class
</span><a href="GHC.Tc.Types.Constraint.html#cc_class"><span class="hs-identifier hs-var">cc_class</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116858"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116858"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: Ct -&gt; [TcType]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116857"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116857"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-500"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; [TcTyVar] -&gt; [TcType] -&gt; Class -&gt; [TcType] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mkStrictSuperClasses"><span class="hs-identifier hs-var">mkStrictSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116859"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116858"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116857"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-501"></span><span>    </span><span class="annot"><a href="#local-6989586621681116867"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CQuantCan"><span class="hs-identifier hs-type">CQuantCan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#QCI"><span class="hs-identifier hs-type">QCI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">qci_pred :: QCInst -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#qci_pred"><span class="hs-identifier hs-var">qci_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116855"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116855"><span class="hs-identifier hs-var">pred</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_ev :: QCInst -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#qci_ev"><span class="hs-identifier hs-var">qci_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116854"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116854"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isClassPred</span><span> </span><span class="hs-identifier">pred</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">pred</span><span> </span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- The cts should all have</span><span>
</span><span id="line-503"></span><span>                                               </span><span class="hs-comment">-- class pred heads</span><span>
</span><span id="line-504"></span><span>        </span><span class="annot"><span class="annottext">CtEvidence
-&gt; [TcTyVar] -&gt; [TcType] -&gt; Class -&gt; [TcType] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mkStrictSuperClasses"><span class="hs-identifier hs-var">mkStrictSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116854"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116852"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116851"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116850"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116849"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-505"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-506"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681116852"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116852"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116851"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116851"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116850"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116850"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116849"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116849"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([TcTyVar], [TcType], Class, [TcType])
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitDFunTy"><span class="hs-identifier hs-var">tcSplitDFunTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116854"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-507"></span><span>    </span><span class="annot"><a href="#local-6989586621681116867"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681116847"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681116847"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS [Ct]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;makeSuperClasses&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681116847"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-508"></span><span>
</span><span id="line-509"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#mkStrictSuperClasses"><span class="hs-identifier hs-type">mkStrictSuperClasses</span></a></span><span>
</span><span id="line-510"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-511"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>  </span><span class="hs-comment">-- These two args are non-empty only when taking</span><span>
</span><span id="line-512"></span><span>                             </span><span class="hs-comment">-- superclasses of a /quantified/ constraint</span><span>
</span><span id="line-513"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-514"></span><span class="hs-comment">-- Return constraints for the strict superclasses of</span><span>
</span><span id="line-515"></span><span class="hs-comment">--   ev :: forall as. theta =&gt; cls tys</span><span>
</span><span id="line-516"></span><span id="mkStrictSuperClasses"><span class="annot"><span class="annottext">mkStrictSuperClasses :: CtEvidence
-&gt; [TcTyVar] -&gt; [TcType] -&gt; Class -&gt; [TcType] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mkStrictSuperClasses"><span class="hs-identifier hs-var hs-var">mkStrictSuperClasses</span></a></span></span><span> </span><span id="local-6989586621681116843"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116843"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116842"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116842"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116841"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116841"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116840"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116840"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116839"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116839"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-517"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameSet
-&gt; CtEvidence
-&gt; [TcTyVar]
-&gt; [TcType]
-&gt; Class
-&gt; [TcType]
-&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_strict_superclasses"><span class="hs-identifier hs-var">mk_strict_superclasses</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#unitNameSet"><span class="hs-identifier hs-var">unitNameSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Name
</span><a href="GHC.Core.Class.html#className"><span class="hs-identifier hs-var hs-var">className</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116840"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-518"></span><span>                           </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116843"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116842"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116841"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116840"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116839"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-519"></span><span>
</span><span id="line-520"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#mk_strict_superclasses"><span class="hs-identifier hs-type">mk_strict_superclasses</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-521"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>
</span><span id="line-522"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-523"></span><span class="hs-comment">-- Always return the immediate superclasses of (cls tys);</span><span>
</span><span id="line-524"></span><span class="hs-comment">-- and expand their superclasses, provided none of them are in rec_clss</span><span>
</span><span id="line-525"></span><span class="hs-comment">-- nor are repeated</span><span>
</span><span id="line-526"></span><span id="mk_strict_superclasses"><span class="annot"><span class="annottext">mk_strict_superclasses :: NameSet
-&gt; CtEvidence
-&gt; [TcTyVar]
-&gt; [TcType]
-&gt; Class
-&gt; [TcType]
-&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_strict_superclasses"><span class="hs-identifier hs-var hs-var">mk_strict_superclasses</span></a></span></span><span> </span><span id="local-6989586621681116835"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116835"><span class="hs-identifier hs-var">rec_clss</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtGiven"><span class="hs-identifier hs-type">CtGiven</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_evar :: CtEvidence -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctev_evar"><span class="hs-identifier hs-var">ctev_evar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116832"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116832"><span class="hs-identifier hs-var">evar</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116830"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116830"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-527"></span><span>                       </span><span id="local-6989586621681116829"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116829"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116828"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116828"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116827"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116827"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116826"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116826"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-528"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; TcS [Ct]) -&gt; [TcTyVar] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m [b]) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier hs-var">concatMapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; TcTyVar -&gt; TcS [Ct]
</span><a href="#local-6989586621681116825"><span class="hs-identifier hs-var">do_one_given</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; CtLoc
</span><a href="#local-6989586621681116824"><span class="hs-identifier hs-var">mk_given_loc</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116830"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([TcTyVar] -&gt; TcS [Ct]) -&gt; [TcTyVar] -&gt; TcS [Ct]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-529"></span><span>    </span><span class="annot"><span class="annottext">Class -&gt; [TcTyVar]
</span><a href="GHC.Core.Class.html#classSCSelIds"><span class="hs-identifier hs-var">classSCSelIds</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116827"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-530"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-531"></span><span>    </span><span id="local-6989586621681116822"><span class="annot"><span class="annottext">dict_ids :: [TcTyVar]
</span><a href="#local-6989586621681116822"><span class="hs-identifier hs-var hs-var">dict_ids</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcTyVar]
</span><a href="GHC.Types.Id.html#mkTemplateLocals"><span class="hs-identifier hs-var">mkTemplateLocals</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116828"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-532"></span><span>    </span><span id="local-6989586621681116821"><span class="annot"><span class="annottext">size :: TypeSize
</span><a href="#local-6989586621681116821"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; TypeSize
</span><a href="GHC.Tc.Utils.TcType.html#sizeTypes"><span class="hs-identifier hs-var">sizeTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116826"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-533"></span><span>
</span><span id="line-534"></span><span>    </span><span id="local-6989586621681116825"><span class="annot"><span class="annottext">do_one_given :: CtLoc -&gt; TcTyVar -&gt; TcS [Ct]
</span><a href="#local-6989586621681116825"><span class="hs-identifier hs-var hs-var">do_one_given</span></a></span></span><span> </span><span id="local-6989586621681116814"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116814"><span class="hs-identifier hs-var">given_loc</span></a></span></span><span> </span><span id="local-6989586621681116813"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116813"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span>
</span><span id="line-535"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; Bool
TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isUnliftedType"><span class="hs-identifier hs-var">isUnliftedType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116811"><span class="hs-identifier hs-var">sc_pred</span></a></span><span>
</span><span id="line-536"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116829"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116828"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-537"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- See Note [Equality superclasses in quantified constraints]</span><span>
</span><span id="line-538"></span><span>        </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-539"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-540"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116810"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116810"><span class="hs-identifier hs-var">given_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (TcType, EvTerm) -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newGivenEvVar"><span class="hs-identifier hs-var">newGivenEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116814"><span class="hs-identifier hs-var">given_loc</span></a></span><span> </span><span class="annot"><span class="annottext">((TcType, EvTerm) -&gt; TcS CtEvidence)
-&gt; (TcType, EvTerm) -&gt; TcS CtEvidence
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-541"></span><span>                         </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType -&gt; (TcType, EvTerm)
</span><a href="#local-6989586621681116808"><span class="hs-identifier hs-var">mk_given_desc</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116813"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116811"><span class="hs-identifier hs-var">sc_pred</span></a></span><span>
</span><span id="line-542"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">NameSet
-&gt; CtEvidence -&gt; [TcTyVar] -&gt; [TcType] -&gt; TcType -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_superclasses"><span class="hs-identifier hs-var">mk_superclasses</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116835"><span class="hs-identifier hs-var">rec_clss</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116810"><span class="hs-identifier hs-var">given_ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116829"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116828"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116811"><span class="hs-identifier hs-var">sc_pred</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-543"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-544"></span><span>        </span><span id="local-6989586621681116811"><span class="annot"><span class="annottext">sc_pred :: TcType
</span><a href="#local-6989586621681116811"><span class="hs-identifier hs-var hs-var">sc_pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.Predicate.html#classMethodInstTy"><span class="hs-identifier hs-var">classMethodInstTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116813"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116826"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-545"></span><span>
</span><span id="line-546"></span><span>      </span><span class="hs-comment">-- See Note [Nested quantified constraint superclasses]</span><span>
</span><span id="line-547"></span><span>    </span><span class="annot"><a href="#local-6989586621681116808"><span class="hs-identifier hs-type">mk_given_desc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvTerm"><span class="hs-identifier hs-type">EvTerm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-548"></span><span>    </span><span id="local-6989586621681116808"><span class="annot"><span class="annottext">mk_given_desc :: TcTyVar -&gt; TcType -&gt; (TcType, EvTerm)
</span><a href="#local-6989586621681116808"><span class="hs-identifier hs-var hs-var">mk_given_desc</span></a></span></span><span> </span><span id="local-6989586621681116803"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116803"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span id="local-6989586621681116802"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116802"><span class="hs-identifier hs-var">sc_pred</span></a></span></span><span>
</span><span id="line-549"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116801"><span class="hs-identifier hs-var">swizzled_pred</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681116800"><span class="hs-identifier hs-var">swizzled_evterm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-550"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-551"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681116799"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116799"><span class="hs-identifier hs-var">sc_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116798"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116798"><span class="hs-identifier hs-var">sc_rho</span></a></span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([TcTyVar], TcType)
</span><a href="GHC.Core.Type.html#splitForAllTys"><span class="hs-identifier hs-var">splitForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116802"><span class="hs-identifier hs-var">sc_pred</span></a></span><span>
</span><span id="line-552"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681116796"><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681116796"><span class="hs-identifier hs-var">sc_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116795"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116795"><span class="hs-identifier hs-var">sc_inner_pred</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([Scaled TcType], TcType)
</span><a href="GHC.Core.Type.html#splitFunTys"><span class="hs-identifier hs-var">splitFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116798"><span class="hs-identifier hs-var">sc_rho</span></a></span><span>
</span><span id="line-553"></span><span>
</span><span id="line-554"></span><span>        </span><span id="local-6989586621681116793"><span class="annot"><span class="annottext">all_tvs :: [TcTyVar]
</span><a href="#local-6989586621681116793"><span class="hs-identifier hs-var hs-var">all_tvs</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116829"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; [TcTyVar] -&gt; [TcTyVar]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#chkAppend"><span class="hs-operator hs-var">`chkAppend`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116799"><span class="hs-identifier hs-var">sc_tvs</span></a></span><span>
</span><span id="line-555"></span><span>        </span><span id="local-6989586621681116791"><span class="annot"><span class="annottext">all_theta :: [TcType]
</span><a href="#local-6989586621681116791"><span class="hs-identifier hs-var hs-var">all_theta</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116828"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType] -&gt; [TcType]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#chkAppend"><span class="hs-operator hs-var">`chkAppend`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Scaled TcType -&gt; TcType) -&gt; [Scaled TcType] -&gt; [TcType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled TcType -&gt; TcType
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681116796"><span class="hs-identifier hs-var">sc_theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-556"></span><span>        </span><span id="local-6989586621681116801"><span class="annot"><span class="annottext">swizzled_pred :: TcType
</span><a href="#local-6989586621681116801"><span class="hs-identifier hs-var hs-var">swizzled_pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; [TcType] -&gt; TcType -&gt; TcType
</span><a href="GHC.Tc.Utils.TcType.html#mkInfSigmaTy"><span class="hs-identifier hs-var">mkInfSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116793"><span class="hs-identifier hs-var">all_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116791"><span class="hs-identifier hs-var">all_theta</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116795"><span class="hs-identifier hs-var">sc_inner_pred</span></a></span><span>
</span><span id="line-557"></span><span>
</span><span id="line-558"></span><span>        </span><span class="hs-comment">-- evar :: forall tvs. theta =&gt; cls tys</span><span>
</span><span id="line-559"></span><span>        </span><span class="hs-comment">-- sel_id :: forall cls_tvs. cls cls_tvs</span><span>
</span><span id="line-560"></span><span>        </span><span class="hs-comment">--                        -&gt; forall sc_tvs. sc_theta =&gt; sc_inner_pred</span><span>
</span><span id="line-561"></span><span>        </span><span class="hs-comment">-- swizzled_evterm :: forall tvs sc_tvs. theta =&gt; sc_theta =&gt; sc_inner_pred</span><span>
</span><span id="line-562"></span><span>        </span><span id="local-6989586621681116800"><span class="annot"><span class="annottext">swizzled_evterm :: EvTerm
</span><a href="#local-6989586621681116800"><span class="hs-identifier hs-var hs-var">swizzled_evterm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvExpr -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#EvExpr"><span class="hs-identifier hs-var">EvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">(EvExpr -&gt; EvTerm) -&gt; EvExpr -&gt; EvTerm
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-563"></span><span>          </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; EvExpr -&gt; EvExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116793"><span class="hs-identifier hs-var">all_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">(EvExpr -&gt; EvExpr) -&gt; EvExpr -&gt; EvExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-564"></span><span>          </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; EvExpr -&gt; EvExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116822"><span class="hs-identifier hs-var">dict_ids</span></a></span><span> </span><span class="annot"><span class="annottext">(EvExpr -&gt; EvExpr) -&gt; EvExpr -&gt; EvExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-565"></span><span>          </span><span class="annot"><span class="annottext">TcTyVar -&gt; EvExpr
forall b. TcTyVar -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116803"><span class="hs-identifier hs-var">sel_id</span></a></span><span>
</span><span id="line-566"></span><span>            </span><span class="annot"><span class="annottext">EvExpr -&gt; [TcType] -&gt; EvExpr
forall b. Expr b -&gt; [TcType] -&gt; Expr b
</span><a href="GHC.Core.html#mkTyApps"><span class="hs-operator hs-var">`mkTyApps`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116826"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-567"></span><span>            </span><span class="annot"><span class="annottext">EvExpr -&gt; EvExpr -&gt; EvExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-operator hs-var">`App`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; EvExpr
</span><a href="GHC.Tc.Types.Evidence.html#evId"><span class="hs-identifier hs-var">evId</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116832"><span class="hs-identifier hs-var">evar</span></a></span><span> </span><span class="annot"><span class="annottext">EvExpr -&gt; [TcTyVar] -&gt; EvExpr
forall b. Expr b -&gt; [TcTyVar] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-operator hs-var">`mkVarApps`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116829"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; [TcTyVar] -&gt; [TcTyVar]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116822"><span class="hs-identifier hs-var">dict_ids</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-568"></span><span>            </span><span class="annot"><span class="annottext">EvExpr -&gt; [TcTyVar] -&gt; EvExpr
forall b. Expr b -&gt; [TcTyVar] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-operator hs-var">`mkVarApps`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116799"><span class="hs-identifier hs-var">sc_tvs</span></a></span><span>
</span><span id="line-569"></span><span>
</span><span id="line-570"></span><span>    </span><span id="local-6989586621681116824"><span class="annot"><span class="annottext">mk_given_loc :: CtLoc -&gt; CtLoc
</span><a href="#local-6989586621681116824"><span class="hs-identifier hs-var hs-var">mk_given_loc</span></a></span></span><span> </span><span id="local-6989586621681116779"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116779"><span class="hs-identifier hs-var">loc</span></a></span></span><span>
</span><span id="line-571"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isCTupleClass"><span class="hs-identifier hs-var">isCTupleClass</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116827"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-572"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116779"><span class="hs-identifier hs-var">loc</span></a></span><span>   </span><span class="hs-comment">-- For tuple predicates, just take them apart, without</span><span>
</span><span id="line-573"></span><span>               </span><span class="hs-comment">-- adding their (large) size into the chain.  When we</span><span>
</span><span id="line-574"></span><span>               </span><span class="hs-comment">-- get down to a base predicate, we'll include its size.</span><span>
</span><span id="line-575"></span><span>               </span><span class="hs-comment">-- #10335</span><span>
</span><span id="line-576"></span><span>
</span><span id="line-577"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#GivenOrigin"><span class="hs-identifier hs-type">GivenOrigin</span></a></span><span> </span><span id="local-6989586621681116776"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681116776"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Constraint.html#ctLocOrigin"><span class="hs-identifier hs-var">ctLocOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116779"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-578"></span><span>         </span><span class="hs-comment">-- See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance</span><span>
</span><span id="line-579"></span><span>         </span><span class="hs-comment">-- for explantation of this transformation for givens</span><span>
</span><span id="line-580"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681116776"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-581"></span><span>            </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InstSkol"><span class="hs-identifier hs-var">InstSkol</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116779"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctl_origin :: CtOrigin
</span><a href="GHC.Tc.Types.Constraint.html#ctl_origin"><span class="hs-identifier hs-var">ctl_origin</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#GivenOrigin"><span class="hs-identifier hs-var">GivenOrigin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeSize -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InstSC"><span class="hs-identifier hs-var">InstSC</span></a></span><span> </span><span class="annot"><span class="annottext">TypeSize
</span><a href="#local-6989586621681116821"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-582"></span><span>            </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#InstSC"><span class="hs-identifier hs-type">InstSC</span></a></span><span> </span><span id="local-6989586621681116772"><span class="annot"><span class="annottext">TypeSize
</span><a href="#local-6989586621681116772"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116779"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctl_origin :: CtOrigin
</span><a href="GHC.Tc.Types.Constraint.html#ctl_origin"><span class="hs-identifier hs-var">ctl_origin</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#GivenOrigin"><span class="hs-identifier hs-var">GivenOrigin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeSize -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InstSC"><span class="hs-identifier hs-var">InstSC</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeSize
</span><a href="#local-6989586621681116772"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TypeSize -&gt; TypeSize -&gt; TypeSize
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-operator hs-var">`max`</span></span><span> </span><span class="annot"><span class="annottext">TypeSize
</span><a href="#local-6989586621681116821"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-583"></span><span>            </span><span class="annot"><span class="annottext">SkolemInfo
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116779"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-584"></span><span>
</span><span id="line-585"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- Probably doesn't happen, since this function</span><span>
</span><span id="line-586"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116779"><span class="hs-identifier hs-var">loc</span></a></span><span>        </span><span class="hs-comment">-- is only used for Givens, but does no harm</span><span>
</span><span id="line-587"></span><span>
</span><span id="line-588"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#mk_strict_superclasses"><span class="hs-identifier hs-var">mk_strict_superclasses</span></a></span><span> </span><span id="local-6989586621681116770"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116770"><span class="hs-identifier hs-var">rec_clss</span></a></span></span><span> </span><span id="local-6989586621681116769"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116769"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116768"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116768"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116767"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116767"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116766"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116766"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116765"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116765"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-589"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; Bool) -&gt; [TcType] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116765"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-590"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- Wanteds with no variables yield no deriveds.</span><span>
</span><span id="line-591"></span><span>              </span><span class="hs-comment">-- See Note [Improvement from Ground Wanteds]</span><span>
</span><span id="line-592"></span><span>
</span><span id="line-593"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-comment">-- Wanted/Derived case, just add Derived superclasses</span><span>
</span><span id="line-594"></span><span>              </span><span class="hs-comment">-- that can lead to improvement.</span><span>
</span><span id="line-595"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">theta</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">theta</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-596"></span><span>    </span><span class="annot"><span class="annottext">(TcType -&gt; TcS [Ct]) -&gt; [TcType] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m [b]) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier hs-var">concatMapM</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcS [Ct]
</span><a href="#local-6989586621681116762"><span class="hs-identifier hs-var">do_one_derived</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [TcType] -&gt; [TcType]
</span><a href="GHC.Tc.Utils.TcType.html#immSuperClasses"><span class="hs-identifier hs-var">immSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116766"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116765"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-597"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-598"></span><span>    </span><span id="local-6989586621681116760"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681116760"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116769"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-599"></span><span>
</span><span id="line-600"></span><span>    </span><span id="local-6989586621681116762"><span class="annot"><span class="annottext">do_one_derived :: TcType -&gt; TcS [Ct]
</span><a href="#local-6989586621681116762"><span class="hs-identifier hs-var hs-var">do_one_derived</span></a></span></span><span> </span><span id="local-6989586621681116758"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116758"><span class="hs-identifier hs-var">sc_pred</span></a></span></span><span>
</span><span id="line-601"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116757"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116757"><span class="hs-identifier hs-var">sc_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; TcType -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newDerivedNC"><span class="hs-identifier hs-var">newDerivedNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116760"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116758"><span class="hs-identifier hs-var">sc_pred</span></a></span><span>
</span><span id="line-602"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">NameSet
-&gt; CtEvidence -&gt; [TcTyVar] -&gt; [TcType] -&gt; TcType -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_superclasses"><span class="hs-identifier hs-var">mk_superclasses</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116770"><span class="hs-identifier hs-var">rec_clss</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116757"><span class="hs-identifier hs-var">sc_ev</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116758"><span class="hs-identifier hs-var">sc_pred</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-603"></span><span>
</span><span id="line-604"></span><span class="hs-comment">{- Note [Improvement from Ground Wanteds]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose class C b a =&gt; D a b
and consider
  [W] D Int Bool
Is there any point in emitting [D] C Bool Int?  No!  The only point of
emitting superclass constraints for W/D constraints is to get
improvement, extra unifications that result from functional
dependencies.  See Note [Why adding superclasses can help] above.

But no variables means no improvement; case closed.
-}</span><span>
</span><span id="line-616"></span><span>
</span><span id="line-617"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#mk_superclasses"><span class="hs-identifier hs-type">mk_superclasses</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-618"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-619"></span><span class="hs-comment">-- Return this constraint, plus its superclasses, if any</span><span>
</span><span id="line-620"></span><span id="mk_superclasses"><span class="annot"><span class="annottext">mk_superclasses :: NameSet
-&gt; CtEvidence -&gt; [TcTyVar] -&gt; [TcType] -&gt; TcType -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_superclasses"><span class="hs-identifier hs-var hs-var">mk_superclasses</span></a></span></span><span> </span><span id="local-6989586621681116755"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116755"><span class="hs-identifier hs-var">rec_clss</span></a></span></span><span> </span><span id="local-6989586621681116754"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116754"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116753"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116753"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116752"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116752"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116751"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116751"><span class="hs-identifier hs-var">pred</span></a></span></span><span>
</span><span id="line-621"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#ClassPred"><span class="hs-identifier hs-type">ClassPred</span></a></span><span> </span><span id="local-6989586621681116750"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116750"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116749"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116749"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116751"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-622"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameSet
-&gt; CtEvidence
-&gt; [TcTyVar]
-&gt; [TcType]
-&gt; Class
-&gt; [TcType]
-&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_superclasses_of"><span class="hs-identifier hs-var">mk_superclasses_of</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116755"><span class="hs-identifier hs-var">rec_clss</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116754"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116753"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116752"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116750"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116749"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-623"></span><span>
</span><span id="line-624"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- Superclass is not a class predicate</span><span>
</span><span id="line-625"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116754"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-626"></span><span>
</span><span id="line-627"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#mk_superclasses_of"><span class="hs-identifier hs-type">mk_superclasses_of</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-628"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-629"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-630"></span><span class="hs-comment">-- Always return this class constraint,</span><span>
</span><span id="line-631"></span><span class="hs-comment">-- and expand its superclasses</span><span>
</span><span id="line-632"></span><span id="mk_superclasses_of"><span class="annot"><span class="annottext">mk_superclasses_of :: NameSet
-&gt; CtEvidence
-&gt; [TcTyVar]
-&gt; [TcType]
-&gt; Class
-&gt; [TcType]
-&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_superclasses_of"><span class="hs-identifier hs-var hs-var">mk_superclasses_of</span></a></span></span><span> </span><span id="local-6989586621681116746"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116746"><span class="hs-identifier hs-var">rec_clss</span></a></span></span><span> </span><span id="local-6989586621681116745"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116745"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116744"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116744"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116743"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116743"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116742"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116741"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116741"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-633"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116740"><span class="hs-identifier hs-var">loop_found</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mk_superclasses_of: loop&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116741"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-634"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681116739"><span class="hs-identifier hs-var">this_ct</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>  </span><span class="hs-comment">-- cc_pend_sc of this_ct = True</span><span>
</span><span id="line-635"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mk_superclasses_of&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116741"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-636"></span><span>                                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isCTupleClass"><span class="hs-identifier hs-var">isCTupleClass</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-637"></span><span>                                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116746"><span class="hs-identifier hs-var">rec_clss</span></a></span><span>
</span><span id="line-638"></span><span>                                                          </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-639"></span><span>                    </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116738"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116738"><span class="hs-identifier hs-var">sc_cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">NameSet
-&gt; CtEvidence
-&gt; [TcTyVar]
-&gt; [TcType]
-&gt; Class
-&gt; [TcType]
-&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mk_strict_superclasses"><span class="hs-identifier hs-var">mk_strict_superclasses</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116737"><span class="hs-identifier hs-var">rec_clss'</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116745"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116744"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116743"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116741"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-640"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681116739"><span class="hs-identifier hs-var">this_ct</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; [Ct] -&gt; [Ct]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116738"><span class="hs-identifier hs-var">sc_cts</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-641"></span><span>                                   </span><span class="hs-comment">-- cc_pend_sc of this_ct = False</span><span>
</span><span id="line-642"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-643"></span><span>    </span><span id="local-6989586621681116736"><span class="annot"><span class="annottext">cls_nm :: Name
</span><a href="#local-6989586621681116736"><span class="hs-identifier hs-var hs-var">cls_nm</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Name
</span><a href="GHC.Core.Class.html#className"><span class="hs-identifier hs-var hs-var">className</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-644"></span><span>    </span><span id="local-6989586621681116740"><span class="annot"><span class="annottext">loop_found :: Bool
</span><a href="#local-6989586621681116740"><span class="hs-identifier hs-var hs-var">loop_found</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isCTupleClass"><span class="hs-identifier hs-var">isCTupleClass</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681116736"><span class="hs-identifier hs-var">cls_nm</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116746"><span class="hs-identifier hs-var">rec_clss</span></a></span><span>
</span><span id="line-645"></span><span>                 </span><span class="hs-comment">-- Tuples never contribute to recursion, and can be nested</span><span>
</span><span id="line-646"></span><span>    </span><span id="local-6989586621681116737"><span class="annot"><span class="annottext">rec_clss' :: NameSet
</span><a href="#local-6989586621681116737"><span class="hs-identifier hs-var hs-var">rec_clss'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681116746"><span class="hs-identifier hs-var">rec_clss</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; Name -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#extendNameSet"><span class="hs-operator hs-var">`extendNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681116736"><span class="hs-identifier hs-var">cls_nm</span></a></span><span>
</span><span id="line-647"></span><span>
</span><span id="line-648"></span><span>    </span><span id="local-6989586621681116739"><span class="annot"><span class="annottext">this_ct :: Ct
</span><a href="#local-6989586621681116739"><span class="hs-identifier hs-var hs-var">this_ct</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116744"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116743"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-649"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CDictCan :: CtEvidence -&gt; Class -&gt; [TcType] -&gt; Bool -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#CDictCan"><span class="hs-identifier hs-type">CDictCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116745"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_class :: Class
</span><a href="GHC.Tc.Types.Constraint.html#cc_class"><span class="hs-identifier hs-var">cc_class</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: [TcType]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116741"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-650"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_pend_sc :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#cc_pend_sc"><span class="hs-identifier hs-var">cc_pend_sc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116740"><span class="hs-identifier hs-var">loop_found</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-651"></span><span>                 </span><span class="hs-comment">-- NB: If there is a loop, we cut off, so we have not</span><span>
</span><span id="line-652"></span><span>                 </span><span class="hs-comment">--     added the superclasses, hence cc_pend_sc = True</span><span>
</span><span id="line-653"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-654"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">QCInst -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#CQuantCan"><span class="hs-identifier hs-var">CQuantCan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">QCI :: CtEvidence -&gt; [TcTyVar] -&gt; TcType -&gt; Bool -&gt; QCInst
</span><a href="GHC.Tc.Types.Constraint.html#QCI"><span class="hs-identifier hs-type">QCI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">qci_tvs :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#qci_tvs"><span class="hs-identifier hs-var">qci_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116744"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_pred :: TcType
</span><a href="GHC.Tc.Types.Constraint.html#qci_pred"><span class="hs-identifier hs-var">qci_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.Predicate.html#mkClassPred"><span class="hs-identifier hs-var">mkClassPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116742"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116741"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-655"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#qci_ev"><span class="hs-identifier hs-var">qci_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116745"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-656"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_pend_sc :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#qci_pend_sc"><span class="hs-identifier hs-var">qci_pend_sc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116740"><span class="hs-identifier hs-var">loop_found</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-657"></span><span>
</span><span id="line-658"></span><span>
</span><span id="line-659"></span><span class="hs-comment">{- Note [Equality superclasses in quantified constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider (#15359, #15593, #15625)
  f :: (forall a. theta =&gt; a ~ b) =&gt; stuff

It's a bit odd to have a local, quantified constraint for `(a~b)`,
but some people want such a thing (see the tickets). And for
Coercible it is definitely useful
  f :: forall m. (forall p q. Coercible p q =&gt; Coercible (m p) (m q)))
                 =&gt; stuff

Moreover it's not hard to arrange; we just need to look up /equality/
constraints in the quantified-constraint environment, which we do in
GHC.Tc.Solver.Interact.doTopReactOther.

There is a wrinkle though, in the case where 'theta' is empty, so
we have
  f :: (forall a. a~b) =&gt; stuff

Now, potentially, the superclass machinery kicks in, in
makeSuperClasses, giving us a a second quantified constraint
       (forall a. a ~# b)
BUT this is an unboxed value!  And nothing has prepared us for
dictionary &quot;functions&quot; that are unboxed.  Actually it does just
about work, but the simplifier ends up with stuff like
   case (/\a. eq_sel d) of df -&gt; ...(df @Int)...
and fails to simplify that any further.  And it doesn't satisfy
isPredTy any more.

So for now we simply decline to take superclasses in the quantified
case.  Instead we have a special case in GHC.Tc.Solver.Interact.doTopReactOther,
which looks for primitive equalities specially in the quantified
constraints.

See also Note [Evidence for quantified constraints] in GHC.Core.Predicate.


************************************************************************
*                                                                      *
*                      Irreducibles canonicalization
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-702"></span><span>
</span><span id="line-703"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canIrred"><span class="hs-identifier hs-type">canIrred</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtIrredStatus"><span class="hs-identifier hs-type">CtIrredStatus</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-704"></span><span class="hs-comment">-- Precondition: ty not a tuple and no other evidence form</span><span>
</span><span id="line-705"></span><span id="canIrred"><span class="annot"><span class="annottext">canIrred :: CtIrredStatus -&gt; CtEvidence -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canIrred"><span class="hs-identifier hs-var hs-var">canIrred</span></a></span></span><span> </span><span id="local-6989586621681116730"><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="#local-6989586621681116730"><span class="hs-identifier hs-var">status</span></a></span></span><span> </span><span id="local-6989586621681116729"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116729"><span class="hs-identifier hs-var">ev</span></a></span></span><span>
</span><span id="line-706"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116728"><span class="annot"><span class="annottext">pred :: TcType
</span><a href="#local-6989586621681116728"><span class="hs-identifier hs-var hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116729"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-707"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;can_pred&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;IrredPred = &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116728"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-708"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116726"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116726"><span class="hs-identifier hs-var">xi</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681116725"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116725"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_FlattenAll"><span class="hs-identifier hs-var">FM_FlattenAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116729"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116728"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="hs-comment">-- co :: xi ~ pred</span><span>
</span><span id="line-709"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TcType -&gt; TcCoercion -&gt; TcS (StopOrContinue CtEvidence)
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-var">rewriteEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116729"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116726"><span class="hs-identifier hs-var">xi</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116725"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">TcS (StopOrContinue CtEvidence)
-&gt; (CtEvidence -&gt; TcS (StopOrContinue Ct))
-&gt; TcS (StopOrContinue Ct)
forall a b.
TcS (StopOrContinue a)
-&gt; (a -&gt; TcS (StopOrContinue b)) -&gt; TcS (StopOrContinue b)
</span><a href="GHC.Tc.Solver.Canonical.html#andWhenContinue"><span class="hs-operator hs-var">`andWhenContinue`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681116721"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116721"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-710"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Re-classify, in case flattening has improved its shape</span><span>
</span><span id="line-711"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116721"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-712"></span><span>           </span><span class="annot"><a href="GHC.Core.Predicate.html#ClassPred"><span class="hs-identifier hs-type">ClassPred</span></a></span><span> </span><span id="local-6989586621681116720"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116720"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681116719"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116719"><span class="hs-identifier hs-var">tys</span></a></span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Class -&gt; [TcType] -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canClassNC"><span class="hs-identifier hs-var">canClassNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116721"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116720"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116719"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-713"></span><span>           </span><span class="annot"><a href="GHC.Core.Predicate.html#EqPred"><span class="hs-identifier hs-type">EqPred</span></a></span><span> </span><span id="local-6989586621681116718"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116718"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116717"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116717"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116716"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116716"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqNC"><span class="hs-identifier hs-var">canEqNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116721"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116718"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116717"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116716"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-714"></span><span>           </span><span class="annot"><span class="annottext">Pred
</span><span class="hs-identifier">_</span></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcS (StopOrContinue Ct)) -&gt; Ct -&gt; TcS (StopOrContinue Ct)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-715"></span><span>                                    </span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkIrredCt"><span class="hs-identifier hs-var">mkIrredCt</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="#local-6989586621681116730"><span class="hs-identifier hs-var">status</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116721"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-716"></span><span>
</span><span id="line-717"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
*                      Quantified predicates
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-722"></span><span>
</span><span id="line-723"></span><span class="hs-comment">{- Note [Quantified constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The -XQuantifiedConstraints extension allows type-class contexts like this:

  data Rose f x = Rose x (f (Rose f x))

  instance (Eq a, forall b. Eq b =&gt; Eq (f b))
        =&gt; Eq (Rose f a)  where
    (Rose x1 rs1) == (Rose x2 rs2) = x1==x2 &amp;&amp; rs1 == rs2

Note the (forall b. Eq b =&gt; Eq (f b)) in the instance contexts.
This quantified constraint is needed to solve the
 [W] (Eq (f (Rose f x)))
constraint which arises form the (==) definition.

The wiki page is
  https://gitlab.haskell.org/ghc/ghc/wikis/quantified-constraints
which in turn contains a link to the GHC Proposal where the change
is specified, and a Haskell Symposium paper about it.

We implement two main extensions to the design in the paper:

 1. We allow a variable in the instance head, e.g.
      f :: forall m a. (forall b. m b) =&gt; D (m a)
    Notice the 'm' in the head of the quantified constraint, not
    a class.

 2. We support superclasses to quantified constraints.
    For example (contrived):
      f :: (Ord b, forall b. Ord b =&gt; Ord (m b)) =&gt; m a -&gt; m a -&gt; Bool
      f x y = x==y
    Here we need (Eq (m a)); but the quantified constraint deals only
    with Ord.  But we can make it work by using its superclass.

Here are the moving parts
  * Language extension {-# LANGUAGE QuantifiedConstraints #-}
    and add it to ghc-boot-th:GHC.LanguageExtensions.Type.Extension

  * A new form of evidence, EvDFun, that is used to discharge
    such wanted constraints

  * checkValidType gets some changes to accept forall-constraints
    only in the right places.

  * Predicate.Pred gets a new constructor ForAllPred, and
    and classifyPredType analyses a PredType to decompose
    the new forall-constraints

  * GHC.Tc.Solver.Monad.InertCans gets an extra field, inert_insts,
    which holds all the Given forall-constraints.  In effect,
    such Given constraints are like local instance decls.

  * When trying to solve a class constraint, via
    GHC.Tc.Solver.Interact.matchInstEnv, use the InstEnv from inert_insts
    so that we include the local Given forall-constraints
    in the lookup.  (See GHC.Tc.Solver.Monad.getInstEnvs.)

  * GHC.Tc.Solver.Canonical.canForAll deals with solving a
    forall-constraint.  See
       Note [Solving a Wanted forall-constraint]

  * We augment the kick-out code to kick out an inert
    forall constraint if it can be rewritten by a new
    type equality; see GHC.Tc.Solver.Monad.kick_out_rewritable

Note that a quantified constraint is never /inferred/
(by GHC.Tc.Solver.simplifyInfer).  A function can only have a
quantified constraint in its type if it is given an explicit
type signature.

-}</span><span>
</span><span id="line-794"></span><span>
</span><span id="line-795"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canForAllNC"><span class="hs-identifier hs-type">canForAllNC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span>
</span><span id="line-796"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-797"></span><span id="canForAllNC"><span class="annot"><span class="annottext">canForAllNC :: CtEvidence
-&gt; [TcTyVar] -&gt; [TcType] -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canForAllNC"><span class="hs-identifier hs-var hs-var">canForAllNC</span></a></span></span><span> </span><span id="local-6989586621681116712"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116712"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116711"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116711"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116710"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116710"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116709"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116709"><span class="hs-identifier hs-var">pred</span></a></span></span><span>
</span><span id="line-798"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isGiven"><span class="hs-identifier hs-var">isGiven</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116712"><span class="hs-identifier hs-var">ev</span></a></span><span>  </span><span class="hs-comment">-- See Note [Eagerly expand given superclasses]</span><span>
</span><span id="line-799"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116708"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116708"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116707"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116707"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (Class, [TcType])
</span><a href="#local-6989586621681116706"><span class="hs-identifier hs-var">cls_pred_tys_maybe</span></a></span><span>
</span><span id="line-800"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116705"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116705"><span class="hs-identifier hs-var">sc_cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; [TcTyVar] -&gt; [TcType] -&gt; Class -&gt; [TcType] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#mkStrictSuperClasses"><span class="hs-identifier hs-var">mkStrictSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116712"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116711"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116710"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681116708"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116707"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-801"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#emitWork"><span class="hs-identifier hs-var">emitWork</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681116705"><span class="hs-identifier hs-var">sc_cts</span></a></span><span>
</span><span id="line-802"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canForAll"><span class="hs-identifier hs-var">canForAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116712"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-803"></span><span>
</span><span id="line-804"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-805"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canForAll"><span class="hs-identifier hs-var">canForAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116712"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (Class, [TcType]) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Class, [TcType])
</span><a href="#local-6989586621681116706"><span class="hs-identifier hs-var">cls_pred_tys_maybe</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-806"></span><span>
</span><span id="line-807"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-808"></span><span>    </span><span id="local-6989586621681116706"><span class="annot"><span class="annottext">cls_pred_tys_maybe :: Maybe (Class, [TcType])
</span><a href="#local-6989586621681116706"><span class="hs-identifier hs-var hs-var">cls_pred_tys_maybe</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (Class, [TcType])
</span><a href="GHC.Core.Predicate.html#getClassPredTys_maybe"><span class="hs-identifier hs-var">getClassPredTys_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116709"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-809"></span><span>
</span><span id="line-810"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canForAll"><span class="hs-identifier hs-type">canForAll</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-811"></span><span class="hs-comment">-- We have a constraint (forall as. blah =&gt; C tys)</span><span>
</span><span id="line-812"></span><span id="canForAll"><span class="annot"><span class="annottext">canForAll :: CtEvidence -&gt; Bool -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canForAll"><span class="hs-identifier hs-var hs-var">canForAll</span></a></span></span><span> </span><span id="local-6989586621681116703"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116703"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116702"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116702"><span class="hs-identifier hs-var">pend_sc</span></a></span></span><span>
</span><span id="line-813"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- First rewrite it to apply the current substitution</span><span>
</span><span id="line-814"></span><span>         </span><span class="hs-comment">-- Do not bother with type-family reductions; we can't</span><span>
</span><span id="line-815"></span><span>         </span><span class="hs-comment">-- do them under a forall anyway (c.f. Flatten.flatten_one</span><span>
</span><span id="line-816"></span><span>         </span><span class="hs-comment">-- on a forall type)</span><span>
</span><span id="line-817"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116701"><span class="annot"><span class="annottext">pred :: TcType
</span><a href="#local-6989586621681116701"><span class="hs-identifier hs-var hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116703"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-818"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116700"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116700"><span class="hs-identifier hs-var">xi</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681116699"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116699"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_SubstOnly"><span class="hs-identifier hs-var">FM_SubstOnly</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116703"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116701"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="hs-comment">-- co :: xi ~ pred</span><span>
</span><span id="line-819"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TcType -&gt; TcCoercion -&gt; TcS (StopOrContinue CtEvidence)
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-var">rewriteEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116703"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116700"><span class="hs-identifier hs-var">xi</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116699"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">TcS (StopOrContinue CtEvidence)
-&gt; (CtEvidence -&gt; TcS (StopOrContinue Ct))
-&gt; TcS (StopOrContinue Ct)
forall a b.
TcS (StopOrContinue a)
-&gt; (a -&gt; TcS (StopOrContinue b)) -&gt; TcS (StopOrContinue b)
</span><a href="GHC.Tc.Solver.Canonical.html#andWhenContinue"><span class="hs-operator hs-var">`andWhenContinue`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681116697"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116697"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-820"></span><span>
</span><span id="line-821"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Now decompose into its pieces and solve it</span><span>
</span><span id="line-822"></span><span>         </span><span class="hs-comment">-- (It takes a lot less code to flatten before decomposing.)</span><span>
</span><span id="line-823"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116697"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-824"></span><span>           </span><span class="annot"><a href="GHC.Core.Predicate.html#ForAllPred"><span class="hs-identifier hs-type">ForAllPred</span></a></span><span> </span><span id="local-6989586621681116696"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116696"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116695"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116695"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116694"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116694"><span class="hs-identifier hs-var">pred</span></a></span></span><span>
</span><span id="line-825"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; [TcTyVar]
-&gt; [TcType]
-&gt; TcType
-&gt; Bool
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#solveForAll"><span class="hs-identifier hs-var">solveForAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116697"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116696"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116695"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116694"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116702"><span class="hs-identifier hs-var">pend_sc</span></a></span><span>
</span><span id="line-826"></span><span>           </span><span class="annot"><span class="annottext">Pred
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS (StopOrContinue Ct)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canForAll&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116697"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-827"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-828"></span><span>
</span><span id="line-829"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#solveForAll"><span class="hs-identifier hs-type">solveForAll</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-830"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-831"></span><span id="solveForAll"><span class="annot"><span class="annottext">solveForAll :: CtEvidence
-&gt; [TcTyVar]
-&gt; [TcType]
-&gt; TcType
-&gt; Bool
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#solveForAll"><span class="hs-identifier hs-var hs-var">solveForAll</span></a></span></span><span> </span><span id="local-6989586621681116692"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116691"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116691"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681116690"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116690"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681116689"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116689"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span id="local-6989586621681116688"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116688"><span class="hs-identifier hs-var">pend_sc</span></a></span></span><span>
</span><span id="line-832"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116685"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116685"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-833"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- See Note [Solving a Wanted forall-constraint]</span><span>
</span><span id="line-834"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116684"><span class="annot"><span class="annottext">skol_info :: SkolemInfo
</span><a href="#local-6989586621681116684"><span class="hs-identifier hs-var hs-var">skol_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#QuantCtxtSkol"><span class="hs-identifier hs-var">QuantCtxtSkol</span></a></span><span>
</span><span id="line-835"></span><span>             </span><span id="local-6989586621681116682"><span class="annot"><span class="annottext">empty_subst :: TCvSubst
</span><a href="#local-6989586621681116682"><span class="hs-identifier hs-var hs-var">empty_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; TCvSubst) -&gt; InScopeSet -&gt; TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; InScopeSet) -&gt; VarSet -&gt; InScopeSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-836"></span><span>                           </span><span class="annot"><span class="annottext">[TcType] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116689"><span class="hs-identifier hs-var">pred</span></a></span><span class="annot"><span class="annottext">TcType -&gt; [TcType] -&gt; [TcType]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116690"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#delVarSetList"><span class="hs-operator hs-var">`delVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116691"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-837"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116679"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116679"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116678"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116678"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [TcTyVar] -&gt; TcS (TCvSubst, [TcTyVar])
</span><a href="GHC.Tc.Solver.Monad.html#tcInstSkolTyVarsX"><span class="hs-identifier hs-var">tcInstSkolTyVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116682"><span class="hs-identifier hs-var">empty_subst</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116691"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-838"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116676"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116676"><span class="hs-identifier hs-var">given_ev_vars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcS TcTyVar) -&gt; [TcType] -&gt; TcS [TcTyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcS TcTyVar
</span><a href="GHC.Tc.Solver.Monad.html#newEvVar"><span class="hs-identifier hs-var">newEvVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [TcType] -&gt; [TcType]
TCvSubst -&gt; [TcType] -&gt; [TcType]
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116679"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116690"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-839"></span><span>
</span><span id="line-840"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116672"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681116672"><span class="hs-identifier hs-var">lvl</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116671"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116671"><span class="hs-identifier hs-var">w_id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116670"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116670"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-841"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcS (TcTyVar, Bag Ct) -&gt; TcS (TcLevel, (TcTyVar, Bag Ct))
forall a. SDoc -&gt; TcS a -&gt; TcS (TcLevel, a)
</span><a href="GHC.Tc.Solver.Monad.html#pushLevelNoWorkList"><span class="hs-identifier hs-var">pushLevelNoWorkList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SkolemInfo -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681116684"><span class="hs-identifier hs-var">skol_info</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcS (TcTyVar, Bag Ct) -&gt; TcS (TcLevel, (TcTyVar, Bag Ct)))
-&gt; TcS (TcTyVar, Bag Ct) -&gt; TcS (TcLevel, (TcTyVar, Bag Ct))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-842"></span><span>                </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116668"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116668"><span class="hs-identifier hs-var">wanted_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; TcType -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newWantedEvVarNC"><span class="hs-identifier hs-var">newWantedEvVarNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116667"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcS CtEvidence) -&gt; TcType -&gt; TcS CtEvidence
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-843"></span><span>                                  </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; TcType -&gt; TcType
TCvSubst -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116679"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116689"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-844"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcTyVar, Bag Ct) -&gt; TcS (TcTyVar, Bag Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctEvEvId"><span class="hs-identifier hs-var">ctEvEvId</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116668"><span class="hs-identifier hs-var">wanted_ev</span></a></span><span>
</span><span id="line-845"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bag Ct
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116668"><span class="hs-identifier hs-var">wanted_ev</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-846"></span><span>
</span><span id="line-847"></span><span>      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116663"><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681116663"><span class="hs-identifier hs-var">ev_binds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel
-&gt; SkolemInfo -&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; Bag Ct -&gt; TcS TcEvBinds
</span><a href="GHC.Tc.Solver.Monad.html#emitImplicationTcS"><span class="hs-identifier hs-var">emitImplicationTcS</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681116672"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681116684"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116678"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span>
</span><span id="line-848"></span><span>                                       </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116676"><span class="hs-identifier hs-var">given_ev_vars</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116670"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-849"></span><span>
</span><span id="line-850"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcEvDest -&gt; EvTerm -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setWantedEvTerm"><span class="hs-identifier hs-var">setWantedEvTerm</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116685"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">(EvTerm -&gt; TcS ()) -&gt; EvTerm -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-851"></span><span>        </span><span class="annot"><span class="annottext">EvFun :: [TcTyVar] -&gt; [TcTyVar] -&gt; TcEvBinds -&gt; TcTyVar -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#EvFun"><span class="hs-identifier hs-type">EvFun</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">et_tvs :: [TcTyVar]
</span><a href="GHC.Tc.Types.Evidence.html#et_tvs"><span class="hs-identifier hs-var">et_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116678"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">et_given :: [TcTyVar]
</span><a href="GHC.Tc.Types.Evidence.html#et_given"><span class="hs-identifier hs-var">et_given</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116676"><span class="hs-identifier hs-var">given_ev_vars</span></a></span><span>
</span><span id="line-852"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">et_binds :: TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#et_binds"><span class="hs-identifier hs-var">et_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681116663"><span class="hs-identifier hs-var">ev_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">et_body :: TcTyVar
</span><a href="GHC.Tc.Types.Evidence.html#et_body"><span class="hs-identifier hs-var">et_body</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116671"><span class="hs-identifier hs-var">w_id</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-853"></span><span>
</span><span id="line-854"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Wanted forall-constraint&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-855"></span><span>
</span><span id="line-856"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isGiven"><span class="hs-identifier hs-var">isGiven</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span>   </span><span class="hs-comment">-- See Note [Solving a Given forall-constraint]</span><span>
</span><span id="line-857"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">QCInst -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#addInertForAll"><span class="hs-identifier hs-var">addInertForAll</span></a></span><span> </span><span class="annot"><span class="annottext">QCInst
</span><a href="#local-6989586621681116654"><span class="hs-identifier hs-var">qci</span></a></span><span>
</span><span id="line-858"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Given forall-constraint&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-859"></span><span>
</span><span id="line-860"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-861"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;discarding derived forall-constraint&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-862"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Derived forall-constraint&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-863"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-864"></span><span>    </span><span id="local-6989586621681116667"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681116667"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-865"></span><span>    </span><span id="local-6989586621681116654"><span class="annot"><span class="annottext">qci :: QCInst
</span><a href="#local-6989586621681116654"><span class="hs-identifier hs-var hs-var">qci</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">QCI :: CtEvidence -&gt; [TcTyVar] -&gt; TcType -&gt; Bool -&gt; QCInst
</span><a href="GHC.Tc.Types.Constraint.html#QCI"><span class="hs-identifier hs-type">QCI</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">qci_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#qci_ev"><span class="hs-identifier hs-var">qci_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116692"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_tvs :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#qci_tvs"><span class="hs-identifier hs-var">qci_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116691"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-866"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_pred :: TcType
</span><a href="GHC.Tc.Types.Constraint.html#qci_pred"><span class="hs-identifier hs-var">qci_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116689"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">qci_pend_sc :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#qci_pend_sc"><span class="hs-identifier hs-var">qci_pend_sc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116688"><span class="hs-identifier hs-var">pend_sc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-867"></span><span>
</span><span id="line-868"></span><span class="hs-comment">{- Note [Solving a Wanted forall-constraint]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Solving a wanted forall (quantified) constraint
  [W] df :: forall ab. (Eq a, Ord b) =&gt; C x a b
is delightfully easy.   Just build an implication constraint
    forall ab. (g1::Eq a, g2::Ord b) =&gt; [W] d :: C x a
and discharge df thus:
    df = /\ab. \g1 g2. let &lt;binds&gt; in d
where &lt;binds&gt; is filled in by solving the implication constraint.
All the machinery is to hand; there is little to do.

Note [Solving a Given forall-constraint]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For a Given constraint
  [G] df :: forall ab. (Eq a, Ord b) =&gt; C x a b
we just add it to TcS's local InstEnv of known instances,
via addInertForall.  Then, if we look up (C x Int Bool), say,
we'll find a match in the InstEnv.


************************************************************************
*                                                                      *
*        Equalities
*                                                                      *
************************************************************************

Note [Canonicalising equalities]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to canonicalise an equality, we look at the structure of the
two types at hand, looking for similarities. A difficulty is that the
types may look dissimilar before flattening but similar after flattening.
However, we don't just want to jump in and flatten right away, because
this might be wasted effort. So, after looking for similarities and failing,
we flatten and then try again. Of course, we don't want to loop, so we
track whether or not we've already flattened.

It is conceivable to do a better job at tracking whether or not a type
is flattened, but this is left as future work. (Mar '15)


Note [Decomposing FunTy]
~~~~~~~~~~~~~~~~~~~~~~~~
can_eq_nc' may attempt to decompose a FunTy that is un-zonked.  This
means that we may very well have a FunTy containing a type of some
unknown kind. For instance, we may have,

    FunTy (a :: k) Int

Where k is a unification variable. So the calls to getRuntimeRep_maybe may
fail (returning Nothing).  In that case we'll fall through, zonk, and try again.
Zonking should fill the variable k, meaning that decomposition will succeed the
second time around.

Also note that we require the AnonArgFlag to match.  This will stop
us decomposing
   (Int -&gt; Bool)  ~  (Show a =&gt; blah)
It's as if we treat (-&gt;) and (=&gt;) as different type constructors.
-}</span><span>
</span><span id="line-926"></span><span>
</span><span id="line-927"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqNC"><span class="hs-identifier hs-type">canEqNC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-928"></span><span id="canEqNC"><span class="annot"><span class="annottext">canEqNC :: CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqNC"><span class="hs-identifier hs-var hs-var">canEqNC</span></a></span></span><span> </span><span id="local-6989586621681116653"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116653"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116652"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116652"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116651"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116651"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116650"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116650"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-929"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116649"><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116649"><span class="hs-identifier hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="GHC.Tc.Solver.Canonical.html#zonk_eq_types"><span class="hs-identifier hs-var">zonk_eq_types</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116651"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116650"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-930"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116649"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-931"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621681116646"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116646"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span id="local-6989586621681116645"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116645"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc"><span class="hs-identifier hs-var">can_eq_nc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116653"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116652"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116646"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116651"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116645"><span class="hs-identifier hs-var">ty2'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116650"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-932"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681116643"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116643"><span class="hs-identifier hs-var">ty</span></a></span></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqReflexive"><span class="hs-identifier hs-var">canEqReflexive</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116653"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116652"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116643"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-933"></span><span>
</span><span id="line-934"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc"><span class="hs-identifier hs-type">can_eq_nc</span></a></span><span>
</span><span id="line-935"></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>            </span><span class="hs-comment">-- True =&gt; both types are flat</span><span>
</span><span id="line-936"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-937"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-938"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>    </span><span class="hs-comment">-- LHS, after and before type-synonym expansion, resp</span><span>
</span><span id="line-939"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>    </span><span class="hs-comment">-- RHS, after and before type-synonym expansion, resp</span><span>
</span><span id="line-940"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-941"></span><span id="can_eq_nc"><span class="annot"><span class="annottext">can_eq_nc :: Bool
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc"><span class="hs-identifier hs-var hs-var">can_eq_nc</span></a></span></span><span> </span><span id="local-6989586621681116641"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116641"><span class="hs-identifier hs-var">flat</span></a></span></span><span> </span><span id="local-6989586621681116640"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116640"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116639"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116639"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116638"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116638"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116637"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116637"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span id="local-6989586621681116636"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116636"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116635"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116635"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-942"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;can_eq_nc&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-943"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116641"><span class="hs-identifier hs-var">flat</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116640"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116639"><span class="hs-identifier hs-var">eq_rel</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116638"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116637"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116636"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116635"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-944"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116634"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116634"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS GlobalRdrEnv
</span><a href="GHC.Tc.Solver.Monad.html#getGlobalRdrEnvTcS"><span class="hs-identifier hs-var">getGlobalRdrEnvTcS</span></a></span><span>
</span><span id="line-945"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116632"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116632"><span class="hs-identifier hs-var">fam_insts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS (FamInstEnv, FamInstEnv)
</span><a href="GHC.Tc.Solver.Monad.html#getFamInstEnvs"><span class="hs-identifier hs-var">getFamInstEnvs</span></a></span><span>
</span><span id="line-946"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; GlobalRdrEnv
-&gt; (FamInstEnv, FamInstEnv)
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116641"><span class="hs-identifier hs-var">flat</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116634"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116632"><span class="hs-identifier hs-var">fam_insts</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116640"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116639"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116638"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116637"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116636"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116635"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-947"></span><span>
</span><span id="line-948"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-type">can_eq_nc'</span></a></span><span>
</span><span id="line-949"></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>           </span><span class="hs-comment">-- True =&gt; both input types are flattened</span><span>
</span><span id="line-950"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrEnv"><span class="hs-identifier hs-type">GlobalRdrEnv</span></a></span><span>   </span><span class="hs-comment">-- needed to see which newtypes are in scope</span><span>
</span><span id="line-951"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier hs-type">FamInstEnvs</span></a></span><span>    </span><span class="hs-comment">-- needed to unwrap data instances</span><span>
</span><span id="line-952"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-953"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-954"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>    </span><span class="hs-comment">-- LHS, after and before type-synonym expansion, resp</span><span>
</span><span id="line-955"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>    </span><span class="hs-comment">-- RHS, after and before type-synonym expansion, resp</span><span>
</span><span id="line-956"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-957"></span><span>
</span><span id="line-958"></span><span class="hs-comment">-- Expand synonyms first; see Note [Type synonyms and canonicalization]</span><span>
</span><span id="line-959"></span><span id="can_eq_nc%27"><span class="annot"><span class="annottext">can_eq_nc' :: Bool
-&gt; GlobalRdrEnv
-&gt; (FamInstEnv, FamInstEnv)
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var hs-var">can_eq_nc'</span></a></span></span><span> </span><span id="local-6989586621681116629"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116629"><span class="hs-identifier hs-var">flat</span></a></span></span><span> </span><span id="local-6989586621681116628"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116628"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116627"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116627"><span class="hs-identifier hs-var">envs</span></a></span></span><span> </span><span id="local-6989586621681116626"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116626"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116625"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116625"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116624"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116624"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116623"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116623"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span id="local-6989586621681116622"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116622"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116621"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116621"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-960"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116620"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116620"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116624"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; GlobalRdrEnv
-&gt; (FamInstEnv, FamInstEnv)
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116629"><span class="hs-identifier hs-var">flat</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116628"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116627"><span class="hs-identifier hs-var">envs</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116626"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116625"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116620"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116623"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116622"><span class="hs-identifier hs-var">ty2</span></a></span><span>  </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116621"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-961"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116618"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116618"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116622"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; GlobalRdrEnv
-&gt; (FamInstEnv, FamInstEnv)
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116629"><span class="hs-identifier hs-var">flat</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116628"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116627"><span class="hs-identifier hs-var">envs</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116626"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116625"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116624"><span class="hs-identifier hs-var">ty1</span></a></span><span>  </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116623"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116618"><span class="hs-identifier hs-var">ty2'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116621"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-962"></span><span>
</span><span id="line-963"></span><span class="hs-comment">-- need to check for reflexivity in the ReprEq case.</span><span>
</span><span id="line-964"></span><span class="hs-comment">-- See Note [Eager reflexivity check]</span><span>
</span><span id="line-965"></span><span class="hs-comment">-- Check only when flat because the zonk_eq_types check in canEqNC takes</span><span>
</span><span id="line-966"></span><span class="hs-comment">-- care of the non-flat case.</span><span>
</span><span id="line-967"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span id="local-6989586621681116617"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116617"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116616"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116616"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116615"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116615"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span id="local-6989586621681116613"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116613"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116612"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116612"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-968"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116613"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-operator hs-var">`tcEqType`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116612"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-969"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqReflexive"><span class="hs-identifier hs-var">canEqReflexive</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116615"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116613"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-970"></span><span>
</span><span id="line-971"></span><span class="hs-comment">-- When working with ReprEq, unwrap newtypes.</span><span>
</span><span id="line-972"></span><span class="hs-comment">-- See Note [Unwrap newtypes first]</span><span>
</span><span id="line-973"></span><span class="hs-comment">-- This must be above the TyVarTy case, in order to guarantee (TyEq:N)</span><span>
</span><span id="line-974"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span id="local-6989586621681116610"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116610"><span class="hs-identifier hs-var">_flat</span></a></span></span><span> </span><span id="local-6989586621681116609"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116609"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116608"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116608"><span class="hs-identifier hs-var">envs</span></a></span></span><span> </span><span id="local-6989586621681116607"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116607"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116606"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116606"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116605"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116605"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116604"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116604"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span id="local-6989586621681116603"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116603"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116602"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116602"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-975"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116606"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-976"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116601"><span class="annot"><span class="annottext">((Bag GlobalRdrElt, TcCoercion), TcType)
</span><a href="#local-6989586621681116601"><span class="hs-identifier hs-var">stuff1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
-&gt; GlobalRdrEnv
-&gt; TcType
-&gt; Maybe ((Bag GlobalRdrElt, TcCoercion), TcType)
</span><a href="GHC.Tc.Instance.Family.html#tcTopNormaliseNewTypeTF_maybe"><span class="hs-identifier hs-var">tcTopNormaliseNewTypeTF_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116608"><span class="hs-identifier hs-var">envs</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116609"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116605"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-977"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; ((Bag GlobalRdrElt, TcCoercion), TcType)
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_newtype_nc"><span class="hs-identifier hs-var">can_eq_newtype_nc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116607"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116605"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">((Bag GlobalRdrElt, TcCoercion), TcType)
</span><a href="#local-6989586621681116601"><span class="hs-identifier hs-var">stuff1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116603"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116602"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-978"></span><span>
</span><span id="line-979"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116606"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-980"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116598"><span class="annot"><span class="annottext">((Bag GlobalRdrElt, TcCoercion), TcType)
</span><a href="#local-6989586621681116598"><span class="hs-identifier hs-var">stuff2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
-&gt; GlobalRdrEnv
-&gt; TcType
-&gt; Maybe ((Bag GlobalRdrElt, TcCoercion), TcType)
</span><a href="GHC.Tc.Instance.Family.html#tcTopNormaliseNewTypeTF_maybe"><span class="hs-identifier hs-var">tcTopNormaliseNewTypeTF_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116608"><span class="hs-identifier hs-var">envs</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116609"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116603"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-981"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; ((Bag GlobalRdrElt, TcCoercion), TcType)
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_newtype_nc"><span class="hs-identifier hs-var">can_eq_newtype_nc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116607"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span>  </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116603"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">((Bag GlobalRdrElt, TcCoercion), TcType)
</span><a href="#local-6989586621681116598"><span class="hs-identifier hs-var">stuff2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116605"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116604"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span>
</span><span id="line-982"></span><span>
</span><span id="line-983"></span><span class="hs-comment">-- Then, get rid of casts</span><span>
</span><span id="line-984"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span id="local-6989586621681116596"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116596"><span class="hs-identifier hs-var">flat</span></a></span></span><span> </span><span id="local-6989586621681116595"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116595"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116594"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116594"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116593"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116593"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116592"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116592"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681116590"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116590"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116589"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116589"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116588"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116588"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116587"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116587"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-985"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isTyVarTy"><span class="hs-identifier hs-var">isTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116588"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See (3) in Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-986"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcType
-&gt; TcCoercion
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqCast"><span class="hs-identifier hs-var">canEqCast</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116596"><span class="hs-identifier hs-var">flat</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116593"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116592"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116590"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116589"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116588"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116587"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-987"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span id="local-6989586621681116584"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116584"><span class="hs-identifier hs-var">flat</span></a></span></span><span> </span><span id="local-6989586621681116583"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116583"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116582"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116582"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116581"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116581"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116580"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116580"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116579"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116579"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116578"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116578"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681116577"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116577"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116576"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116576"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-988"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isTyVarTy"><span class="hs-identifier hs-var">isTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116579"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See (3) in Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-989"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcType
-&gt; TcCoercion
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqCast"><span class="hs-identifier hs-var">canEqCast</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116584"><span class="hs-identifier hs-var">flat</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116581"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116580"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116577"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116576"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116579"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116578"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span>
</span><span id="line-990"></span><span>
</span><span id="line-991"></span><span class="hs-comment">-- NB: pattern match on True: we want only flat types sent to canEqTyVar.</span><span>
</span><span id="line-992"></span><span class="hs-comment">-- See also Note [No top-level newtypes on RHS of representational equalities]</span><span>
</span><span id="line-993"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span id="local-6989586621681116575"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116575"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116574"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116574"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116573"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116573"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116572"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116572"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681116570"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116570"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681116569"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116569"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span id="local-6989586621681116568"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116568"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116567"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116567"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-994"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar"><span class="hs-identifier hs-var">canEqTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116573"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116572"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116570"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116569"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116568"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116567"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-995"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span id="local-6989586621681116565"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116565"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116564"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116564"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116563"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116563"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116562"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116562"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116561"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116561"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116560"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116560"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681116559"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116559"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681116558"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116558"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-996"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar"><span class="hs-identifier hs-var">canEqTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116563"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116562"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116559"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116558"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116561"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116560"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span>
</span><span id="line-997"></span><span>
</span><span id="line-998"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-999"></span><span class="hs-comment">-- Otherwise try to decompose</span><span>
</span><span id="line-1000"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1001"></span><span>
</span><span id="line-1002"></span><span class="hs-comment">-- Literals</span><span>
</span><span id="line-1003"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span id="local-6989586621681116557"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116557"><span class="hs-identifier hs-var">_flat</span></a></span></span><span> </span><span id="local-6989586621681116556"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116556"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116555"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116555"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116554"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116554"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116553"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116553"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116552"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681116552"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621681116550"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116550"><span class="hs-identifier hs-var">l1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621681116549"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116549"><span class="hs-identifier hs-var">l2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1004"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116550"><span class="hs-identifier hs-var">l1</span></a></span><span> </span><span class="annot"><span class="annottext">TyLit -&gt; TyLit -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116549"><span class="hs-identifier hs-var">l2</span></a></span><span>
</span><span id="line-1005"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EvTerm -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setEvBindIfWanted"><span class="hs-identifier hs-var">setEvBindIfWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116554"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">(TcCoercion -&gt; EvTerm) -&gt; TcCoercion -&gt; EvTerm
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116553"><span class="hs-identifier hs-var">eq_rel</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116552"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1006"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116554"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Equal LitTy&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1007"></span><span>
</span><span id="line-1008"></span><span class="hs-comment">-- Decompose FunTy: (s -&gt; t) and (c =&gt; t)</span><span>
</span><span id="line-1009"></span><span class="hs-comment">-- NB: don't decompose (Int -&gt; blah) ~ (Show a =&gt; blah)</span><span>
</span><span id="line-1010"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span id="local-6989586621681116545"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116545"><span class="hs-identifier hs-var">_flat</span></a></span></span><span> </span><span id="local-6989586621681116544"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116544"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116543"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116543"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116542"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116542"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116541"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116541"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span>
</span><span id="line-1011"></span><span>           </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_mult :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116538"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116538"><span class="hs-identifier hs-var">am1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_af :: TcType -&gt; AnonArgFlag
</span><a href="GHC.Core.TyCo.Rep.html#ft_af"><span class="hs-identifier hs-var">ft_af</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116536"><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681116536"><span class="hs-identifier hs-var">af1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_arg :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116534"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116534"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116532"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116532"><span class="hs-identifier hs-var">ty1b</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1012"></span><span>           </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_mult :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116531"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116531"><span class="hs-identifier hs-var">am2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_af :: TcType -&gt; AnonArgFlag
</span><a href="GHC.Core.TyCo.Rep.html#ft_af"><span class="hs-identifier hs-var">ft_af</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116530"><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681116530"><span class="hs-identifier hs-var">af2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_arg :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116529"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116529"><span class="hs-identifier hs-var">ty2a</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116528"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116528"><span class="hs-identifier hs-var">ty2b</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1013"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681116536"><span class="hs-identifier hs-var">af1</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag -&gt; AnonArgFlag -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681116530"><span class="hs-identifier hs-var">af2</span></a></span><span>   </span><span class="hs-comment">-- Don't decompose (Int -&gt; blah) ~ (Show a =&gt; blah)</span><span>
</span><span id="line-1014"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116527"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116527"><span class="hs-identifier hs-var">ty1a_rep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; Maybe TcType
TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#getRuntimeRep_maybe"><span class="hs-identifier hs-var">getRuntimeRep_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116534"><span class="hs-identifier hs-var">ty1a</span></a></span><span>  </span><span class="hs-comment">-- getRutimeRep_maybe:</span><span>
</span><span id="line-1015"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116525"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116525"><span class="hs-identifier hs-var">ty1b_rep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; Maybe TcType
TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#getRuntimeRep_maybe"><span class="hs-identifier hs-var">getRuntimeRep_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116532"><span class="hs-identifier hs-var">ty1b</span></a></span><span>  </span><span class="hs-comment">-- see Note [Decomposing FunTy]</span><span>
</span><span id="line-1016"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116524"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116524"><span class="hs-identifier hs-var">ty2a_rep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; Maybe TcType
TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#getRuntimeRep_maybe"><span class="hs-identifier hs-var">getRuntimeRep_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116529"><span class="hs-identifier hs-var">ty2a</span></a></span><span>
</span><span id="line-1017"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681116523"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116523"><span class="hs-identifier hs-var">ty2b_rep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; Maybe TcType
TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#getRuntimeRep_maybe"><span class="hs-identifier hs-var">getRuntimeRep_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116528"><span class="hs-identifier hs-var">ty2b</span></a></span><span>
</span><span id="line-1018"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; TyCon
-&gt; [TcType]
-&gt; [TcType]
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canDecomposableTyConAppOK"><span class="hs-identifier hs-var">canDecomposableTyConAppOK</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116542"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116541"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#funTyCon"><span class="hs-identifier hs-var">funTyCon</span></a></span><span>
</span><span id="line-1019"></span><span>                              </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116538"><span class="hs-identifier hs-var">am1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116527"><span class="hs-identifier hs-var">ty1a_rep</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116525"><span class="hs-identifier hs-var">ty1b_rep</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116534"><span class="hs-identifier hs-var">ty1a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116532"><span class="hs-identifier hs-var">ty1b</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1020"></span><span>                              </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116531"><span class="hs-identifier hs-var">am2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116524"><span class="hs-identifier hs-var">ty2a_rep</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116523"><span class="hs-identifier hs-var">ty2b_rep</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116529"><span class="hs-identifier hs-var">ty2a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116528"><span class="hs-identifier hs-var">ty2b</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1021"></span><span>
</span><span id="line-1022"></span><span class="hs-comment">-- Decompose type constructor applications</span><span>
</span><span id="line-1023"></span><span class="hs-comment">-- NB: e have expanded type synonyms already</span><span>
</span><span id="line-1024"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span id="local-6989586621681116520"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116520"><span class="hs-identifier hs-var">_flat</span></a></span></span><span> </span><span id="local-6989586621681116519"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116519"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116518"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116518"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116517"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116517"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116516"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116516"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span>
</span><span id="line-1025"></span><span>           </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681116514"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116514"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621681116513"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116513"><span class="hs-identifier hs-var">tys1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1026"></span><span>           </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681116512"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116512"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621681116511"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116511"><span class="hs-identifier hs-var">tys2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1027"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeFamilyTyCon"><span class="hs-identifier hs-var">isTypeFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116514"><span class="hs-identifier hs-var">tc1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1028"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeFamilyTyCon"><span class="hs-identifier hs-var">isTypeFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116512"><span class="hs-identifier hs-var">tc2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1029"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; TyCon
-&gt; [TcType]
-&gt; TyCon
-&gt; [TcType]
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canTyConApp"><span class="hs-identifier hs-var">canTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116517"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116516"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116514"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116513"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116512"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116511"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1030"></span><span>
</span><span id="line-1031"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span id="local-6989586621681116508"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116508"><span class="hs-identifier hs-var">_flat</span></a></span></span><span> </span><span id="local-6989586621681116507"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116507"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116506"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116506"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116505"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116505"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116504"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116504"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span>
</span><span id="line-1032"></span><span>           </span><span id="local-6989586621681116503"><span class="annot"><span class="annottext">s1 :: TcType
</span><a href="#local-6989586621681116503"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116501"><span class="annot"><span class="annottext">s2 :: TcType
</span><a href="#local-6989586621681116501"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1033"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc_forall"><span class="hs-identifier hs-var">can_eq_nc_forall</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116505"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116504"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116503"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116501"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1034"></span><span>
</span><span id="line-1035"></span><span class="hs-comment">-- See Note [Canonicalising type applications] about why we require flat types</span><span>
</span><span id="line-1036"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span id="local-6989586621681116499"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116499"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116498"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116498"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116497"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116497"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116496"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116496"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681116494"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116494"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681116493"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116493"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116492"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116492"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1037"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#NomEq"><span class="hs-identifier hs-var">NomEq</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116496"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-1038"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116490"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116490"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116489"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116489"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitAppTy_maybe"><span class="hs-identifier hs-var">tcSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116492"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1039"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_app"><span class="hs-identifier hs-var">can_eq_app</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116497"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116494"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116493"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116490"><span class="hs-identifier hs-var">t2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116489"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1040"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span id="local-6989586621681116486"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116486"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116485"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116485"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116484"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116484"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116483"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116483"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116482"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116482"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681116481"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116481"><span class="hs-identifier hs-var">t2</span></a></span></span><span> </span><span id="local-6989586621681116480"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116480"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1041"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#NomEq"><span class="hs-identifier hs-var">NomEq</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116483"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-1042"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116479"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116479"><span class="hs-identifier hs-var">t1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116478"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116478"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitAppTy_maybe"><span class="hs-identifier hs-var">tcSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116482"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1043"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_app"><span class="hs-identifier hs-var">can_eq_app</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116484"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116479"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116478"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116481"><span class="hs-identifier hs-var">t2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116480"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1044"></span><span>
</span><span id="line-1045"></span><span class="hs-comment">-- No similarity in type structure detected. Flatten and try again.</span><span>
</span><span id="line-1046"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span id="local-6989586621681116477"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116477"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116476"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116476"><span class="hs-identifier hs-var">envs</span></a></span></span><span> </span><span id="local-6989586621681116475"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116475"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116474"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116474"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116473"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116473"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116472"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116472"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-1047"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116471"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116471"><span class="hs-identifier hs-var">xi1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116470"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116470"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_FlattenAll"><span class="hs-identifier hs-var">FM_FlattenAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116475"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116473"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span>
</span><span id="line-1048"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116469"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116469"><span class="hs-identifier hs-var">xi2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116468"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116468"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_FlattenAll"><span class="hs-identifier hs-var">FM_FlattenAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116475"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116472"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-1049"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116467"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116467"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116475"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116471"><span class="hs-identifier hs-var">xi1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116469"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116470"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116468"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-1050"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; GlobalRdrEnv
-&gt; (FamInstEnv, FamInstEnv)
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116477"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116476"><span class="hs-identifier hs-var">envs</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116467"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116474"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116471"><span class="hs-identifier hs-var">xi1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116471"><span class="hs-identifier hs-var">xi1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116469"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116469"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1051"></span><span>
</span><span id="line-1052"></span><span class="hs-comment">-- We've flattened and the types don't match. Give up.</span><span>
</span><span id="line-1053"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc%27"><span class="hs-identifier hs-var">can_eq_nc'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span id="local-6989586621681116465"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681116465"><span class="hs-identifier hs-var">_rdr_env</span></a></span></span><span> </span><span id="local-6989586621681116464"><span class="annot"><span class="annottext">(FamInstEnv, FamInstEnv)
</span><a href="#local-6989586621681116464"><span class="hs-identifier hs-var">_envs</span></a></span></span><span> </span><span id="local-6989586621681116463"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116463"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116462"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116462"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116461"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116461"><span class="hs-identifier hs-var">ps_ty1</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681116460"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116460"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-1054"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;can_eq_nc' catch-all case&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116461"><span class="hs-identifier hs-var">ps_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116460"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1055"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116462"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-comment">-- See Note [Unsolved equalities]</span><span>
</span><span id="line-1056"></span><span>            </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkIrredCt"><span class="hs-identifier hs-var">mkIrredCt</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#OtherCIS"><span class="hs-identifier hs-var">OtherCIS</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116463"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1057"></span><span>            </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#NomEq"><span class="hs-identifier hs-var">NomEq</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkIrredCt"><span class="hs-identifier hs-var">mkIrredCt</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#InsolubleCIS"><span class="hs-identifier hs-var">InsolubleCIS</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116463"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1058"></span><span>          </span><span class="hs-comment">-- No need to call canEqFailure/canEqHardFailure because they</span><span>
</span><span id="line-1059"></span><span>          </span><span class="hs-comment">-- flatten, and the types involved here are already flat</span><span>
</span><span id="line-1060"></span><span>
</span><span id="line-1061"></span><span class="hs-comment">{- Note [Unsolved equalities]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we have an unsolved equality like
  (a b ~R# Int)
that is not necessarily insoluble!  Maybe 'a' will turn out to be a newtype.
So we want to make it a potentially-soluble Irred not an insoluble one.
Missing this point is what caused #15431
-}</span><span>
</span><span id="line-1069"></span><span>
</span><span id="line-1070"></span><span class="hs-comment">---------------------------------</span><span>
</span><span id="line-1071"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc_forall"><span class="hs-identifier hs-type">can_eq_nc_forall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-1072"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>    </span><span class="hs-comment">-- LHS and RHS</span><span>
</span><span id="line-1073"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1074"></span><span class="hs-comment">-- (forall as. phi1) ~ (forall bs. phi2)</span><span>
</span><span id="line-1075"></span><span class="hs-comment">-- Check for length match of as, bs</span><span>
</span><span id="line-1076"></span><span class="hs-comment">-- Then build an implication constraint: forall as. phi1 ~ phi2[as/bs]</span><span>
</span><span id="line-1077"></span><span class="hs-comment">-- But remember also to unify the kinds of as and bs</span><span>
</span><span id="line-1078"></span><span class="hs-comment">--  (this is the 'go' loop), and actually substitute phi2[as |&gt; cos / bs]</span><span>
</span><span id="line-1079"></span><span class="hs-comment">-- Remember also that we might have forall z (a:z). blah</span><span>
</span><span id="line-1080"></span><span class="hs-comment">--  so we must proceed one binder at a time (#13879)</span><span>
</span><span id="line-1081"></span><span>
</span><span id="line-1082"></span><span id="can_eq_nc_forall"><span class="annot"><span class="annottext">can_eq_nc_forall :: CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc_forall"><span class="hs-identifier hs-var hs-var">can_eq_nc_forall</span></a></span></span><span> </span><span id="local-6989586621681116458"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116458"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116457"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116457"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116456"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116456"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621681116455"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116455"><span class="hs-identifier hs-var">s2</span></a></span></span><span>
</span><span id="line-1083"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116454"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116454"><span class="hs-identifier hs-var">loc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116453"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116453"><span class="hs-identifier hs-var">orig_dest</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116458"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1084"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116452"><span class="annot"><span class="annottext">free_tvs :: VarSet
</span><a href="#local-6989586621681116452"><span class="hs-identifier hs-var hs-var">free_tvs</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116456"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116455"><span class="hs-identifier hs-var">s2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1085"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621681116451"><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116451"><span class="hs-identifier hs-var">bndrs1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116450"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116450"><span class="hs-identifier hs-var">phi1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([TyVarBinder], TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllVarBndrs"><span class="hs-identifier hs-var">tcSplitForAllVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116456"><span class="hs-identifier hs-var">s1</span></a></span><span>
</span><span id="line-1086"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621681116448"><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116448"><span class="hs-identifier hs-var">bndrs2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116447"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116447"><span class="hs-identifier hs-var">phi2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([TyVarBinder], TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllVarBndrs"><span class="hs-identifier hs-var">tcSplitForAllVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116455"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1087"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyVarBinder] -&gt; [TyVarBinder] -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-identifier hs-var">equalLength</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116451"><span class="hs-identifier hs-var">bndrs1</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116448"><span class="hs-identifier hs-var">bndrs2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1088"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Forall failure&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1089"></span><span>                     </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116456"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116455"><span class="hs-identifier hs-var">s2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TyVarBinder] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116451"><span class="hs-identifier hs-var">bndrs1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TyVarBinder] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116448"><span class="hs-identifier hs-var">bndrs2</span></a></span><span>
</span><span id="line-1090"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[ArgFlag] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyVarBinder -&gt; ArgFlag) -&gt; [TyVarBinder] -&gt; [ArgFlag]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyVarBinder -&gt; ArgFlag
forall tv argf. VarBndr tv argf -&gt; argf
</span><a href="GHC.Types.Var.html#binderArgFlag"><span class="hs-identifier hs-var">binderArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116451"><span class="hs-identifier hs-var">bndrs1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1091"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[ArgFlag] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyVarBinder -&gt; ArgFlag) -&gt; [TyVarBinder] -&gt; [ArgFlag]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyVarBinder -&gt; ArgFlag
forall tv argf. VarBndr tv argf -&gt; argf
</span><a href="GHC.Types.Var.html#binderArgFlag"><span class="hs-identifier hs-var">binderArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116448"><span class="hs-identifier hs-var">bndrs2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1092"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqHardFailure"><span class="hs-identifier hs-var">canEqHardFailure</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116458"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116456"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116455"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1093"></span><span>        </span><span class="hs-keyword">else</span><span>
</span><span id="line-1094"></span><span>   </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Creating implication for polytype equality&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116458"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1095"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116443"><span class="annot"><span class="annottext">empty_subst1 :: TCvSubst
</span><a href="#local-6989586621681116443"><span class="hs-identifier hs-var hs-var">empty_subst1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; TCvSubst) -&gt; InScopeSet -&gt; TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681116452"><span class="hs-identifier hs-var">free_tvs</span></a></span><span>
</span><span id="line-1096"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116442"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116442"><span class="hs-identifier hs-var">subst1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116441"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116441"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [TcTyVar] -&gt; TcS (TCvSubst, [TcTyVar])
</span><a href="GHC.Tc.Solver.Monad.html#tcInstSkolTyVarsX"><span class="hs-identifier hs-var">tcInstSkolTyVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116443"><span class="hs-identifier hs-var">empty_subst1</span></a></span><span> </span><span class="annot"><span class="annottext">([TcTyVar] -&gt; TcS (TCvSubst, [TcTyVar]))
-&gt; [TcTyVar] -&gt; TcS (TCvSubst, [TcTyVar])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1097"></span><span>                              </span><span class="annot"><span class="annottext">[TyVarBinder] -&gt; [TcTyVar]
forall tv argf. [VarBndr tv argf] -&gt; [tv]
</span><a href="GHC.Types.Var.html#binderVars"><span class="hs-identifier hs-var">binderVars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116451"><span class="hs-identifier hs-var">bndrs1</span></a></span><span>
</span><span id="line-1098"></span><span>
</span><span id="line-1099"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116439"><span class="annot"><span class="annottext">skol_info :: SkolemInfo
</span><a href="#local-6989586621681116439"><span class="hs-identifier hs-var hs-var">skol_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#UnifyForAllSkol"><span class="hs-identifier hs-var">UnifyForAllSkol</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116450"><span class="hs-identifier hs-var">phi1</span></a></span><span>
</span><span id="line-1100"></span><span>            </span><span id="local-6989586621681116435"><span class="annot"><span class="annottext">phi1' :: TcType
</span><a href="#local-6989586621681116435"><span class="hs-identifier hs-var hs-var">phi1'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; TcType -&gt; TcType
TCvSubst -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116442"><span class="hs-identifier hs-var">subst1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116450"><span class="hs-identifier hs-var">phi1</span></a></span><span>
</span><span id="line-1101"></span><span>
</span><span id="line-1102"></span><span>            </span><span class="hs-comment">-- Unify the kinds, extend the substitution</span><span>
</span><span id="line-1103"></span><span>            </span><span class="annot"><a href="#local-6989586621681116434"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVarBinder"><span class="hs-identifier hs-type">TyVarBinder</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1104"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1105"></span><span>            </span><span id="local-6989586621681116434"><span class="annot"><span class="annottext">go :: [TcTyVar] -&gt; TCvSubst -&gt; [TyVarBinder] -&gt; TcS (TcCoercion, Bag Ct)
</span><a href="#local-6989586621681116434"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116432"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116432"><span class="hs-identifier hs-var">skol_tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681116431"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116431"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681116430"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116430"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116429"><span class="annot"><span class="annottext">TyVarBinder
</span><a href="#local-6989586621681116429"><span class="hs-identifier hs-var">bndr2</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681116428"><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116428"><span class="hs-identifier hs-var">bndrs2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1106"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116427"><span class="annot"><span class="annottext">tv2 :: TcTyVar
</span><a href="#local-6989586621681116427"><span class="hs-identifier hs-var hs-var">tv2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVarBinder -&gt; TcTyVar
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVarBinder
</span><a href="#local-6989586621681116429"><span class="hs-identifier hs-var">bndr2</span></a></span><span>
</span><span id="line-1107"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116425"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116425"><span class="hs-identifier hs-var">kind_co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116424"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116424"><span class="hs-identifier hs-var">wanteds1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS (TcCoercion, Bag Ct)
</span><a href="#local-6989586621681116423"><span class="hs-identifier hs-var">unify</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116454"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116432"><span class="hs-identifier hs-var">skol_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1108"></span><span>                                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; TcType -&gt; TcType
TCvSubst -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116430"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116427"><span class="hs-identifier hs-var">tv2</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1109"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116421"><span class="annot"><span class="annottext">subst' :: TCvSubst
</span><a href="#local-6989586621681116421"><span class="hs-identifier hs-var hs-var">subst'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TcTyVar -&gt; TcType -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier hs-var">extendTvSubstAndInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116430"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116427"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1110"></span><span>                                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion -&gt; TcType
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-identifier hs-var">mkCastTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116432"><span class="hs-identifier hs-var">skol_tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116425"><span class="hs-identifier hs-var">kind_co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1111"></span><span>                         </span><span class="hs-comment">-- skol_tv is already in the in-scope set, but the</span><span>
</span><span id="line-1112"></span><span>                         </span><span class="hs-comment">-- free vars of kind_co are not; hence &quot;...AndInScope&quot;</span><span>
</span><span id="line-1113"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116418"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116418"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116417"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116417"><span class="hs-identifier hs-var">wanteds2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; TCvSubst -&gt; [TyVarBinder] -&gt; TcS (TcCoercion, Bag Ct)
</span><a href="#local-6989586621681116434"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116431"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116421"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116428"><span class="hs-identifier hs-var">bndrs2</span></a></span><span>
</span><span id="line-1114"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcCoercion, Bag Ct) -&gt; TcS (TcCoercion, Bag Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcForAllCo"><span class="hs-identifier hs-var">mkTcForAllCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116432"><span class="hs-identifier hs-var">skol_tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116425"><span class="hs-identifier hs-var">kind_co</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116418"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1115"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116424"><span class="hs-identifier hs-var">wanteds1</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct -&gt; Bag Ct -&gt; Bag Ct
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116417"><span class="hs-identifier hs-var">wanteds2</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1116"></span><span>
</span><span id="line-1117"></span><span>            </span><span class="hs-comment">-- Done: unify phi1 ~ phi2</span><span>
</span><span id="line-1118"></span><span>            </span><span class="annot"><a href="#local-6989586621681116434"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621681116414"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116414"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681116413"><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116413"><span class="hs-identifier hs-var">bndrs2</span></a></span></span><span>
</span><span id="line-1119"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">bndrs2</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1120"></span><span>                </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS (TcCoercion, Bag Ct)
</span><a href="#local-6989586621681116423"><span class="hs-identifier hs-var">unify</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116454"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116457"><span class="hs-identifier hs-var">eq_rel</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116435"><span class="hs-identifier hs-var">phi1'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">substTyUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116414"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116447"><span class="hs-identifier hs-var">phi2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1121"></span><span>
</span><span id="line-1122"></span><span>            </span><span class="annot"><a href="#local-6989586621681116434"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcS (TcCoercion, Bag Ct)
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cna_eq_nc_forall&quot;</span></span><span>  </span><span class="hs-comment">-- case (s:ss) []</span><span>
</span><span id="line-1123"></span><span>
</span><span id="line-1124"></span><span>            </span><span id="local-6989586621681116410"><span class="annot"><span class="annottext">empty_subst2 :: TCvSubst
</span><a href="#local-6989586621681116410"><span class="hs-identifier hs-var hs-var">empty_subst2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; InScopeSet
</span><a href="GHC.Core.TyCo.Subst.html#getTCvInScope"><span class="hs-identifier hs-var">getTCvInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116442"><span class="hs-identifier hs-var">subst1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1125"></span><span>
</span><span id="line-1126"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116408"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681116408"><span class="hs-identifier hs-var">lvl</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116407"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116407"><span class="hs-identifier hs-var">all_co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116406"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116406"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SDoc
-&gt; TcS (TcCoercion, Bag Ct) -&gt; TcS (TcLevel, (TcCoercion, Bag Ct))
forall a. SDoc -&gt; TcS a -&gt; TcS (TcLevel, a)
</span><a href="GHC.Tc.Solver.Monad.html#pushLevelNoWorkList"><span class="hs-identifier hs-var">pushLevelNoWorkList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SkolemInfo -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681116439"><span class="hs-identifier hs-var">skol_info</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcS (TcCoercion, Bag Ct) -&gt; TcS (TcLevel, (TcCoercion, Bag Ct)))
-&gt; TcS (TcCoercion, Bag Ct) -&gt; TcS (TcLevel, (TcCoercion, Bag Ct))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1127"></span><span>                                    </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; TCvSubst -&gt; [TyVarBinder] -&gt; TcS (TcCoercion, Bag Ct)
</span><a href="#local-6989586621681116434"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116441"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681116410"><span class="hs-identifier hs-var">empty_subst2</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVarBinder]
</span><a href="#local-6989586621681116448"><span class="hs-identifier hs-var">bndrs2</span></a></span><span>
</span><span id="line-1128"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SkolemInfo -&gt; [TcTyVar] -&gt; Bag Ct -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#emitTvImplicationTcS"><span class="hs-identifier hs-var">emitTvImplicationTcS</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681116408"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681116439"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681116441"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681116406"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-1129"></span><span>
</span><span id="line-1130"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcEvDest -&gt; TcCoercion -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setWantedEq"><span class="hs-identifier hs-var">setWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116453"><span class="hs-identifier hs-var">orig_dest</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116407"><span class="hs-identifier hs-var">all_co</span></a></span><span>
</span><span id="line-1131"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116458"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Deferred polytype equality&quot;</span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1132"></span><span>
</span><span id="line-1133"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1134"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Omitting decomposition of given polytype equality&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1135"></span><span>        </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; SDoc
</span><a href="GHC.Tc.Solver.Monad.html#pprEq"><span class="hs-identifier hs-var">pprEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116456"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116455"><span class="hs-identifier hs-var">s2</span></a></span><span>    </span><span class="hs-comment">-- See Note [Do not decompose given polytype equalities]</span><span>
</span><span id="line-1136"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116458"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Discard given polytype equality&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1137"></span><span>
</span><span id="line-1138"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1139"></span><span>    </span><span class="annot"><a href="#local-6989586621681116423"><span class="hs-identifier hs-type">unify</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtLoc"><span class="hs-identifier hs-type">CtLoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1140"></span><span>    </span><span class="hs-comment">-- This version returns the wanted constraint rather</span><span>
</span><span id="line-1141"></span><span>    </span><span class="hs-comment">-- than putting it in the work list</span><span>
</span><span id="line-1142"></span><span>    </span><span id="local-6989586621681116423"><span class="annot"><span class="annottext">unify :: CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS (TcCoercion, Bag Ct)
</span><a href="#local-6989586621681116423"><span class="hs-identifier hs-var hs-var">unify</span></a></span></span><span> </span><span id="local-6989586621681116402"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116402"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681116401"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116401"><span class="hs-keyword hs-var">role</span></a></span></span><span> </span><span id="local-6989586621681116400"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116400"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116399"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116399"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1143"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116400"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-operator hs-var">`tcEqType`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116399"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1144"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcCoercion, Bag Ct) -&gt; TcS (TcCoercion, Bag Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116401"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116400"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Ct
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1145"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1146"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116396"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116396"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116395"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116395"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS (CtEvidence, TcCoercion)
</span><a href="GHC.Tc.Solver.Monad.html#newWantedEq"><span class="hs-identifier hs-var">newWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116402"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116401"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116400"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116399"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1147"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcCoercion, Bag Ct) -&gt; TcS (TcCoercion, Bag Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116395"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bag Ct
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116396"><span class="hs-identifier hs-var">wanted</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1148"></span><span>
</span><span id="line-1149"></span><span class="hs-comment">---------------------------------</span><span>
</span><span id="line-1150"></span><span class="hs-comment">-- | Compare types for equality, while zonking as necessary. Gives up</span><span>
</span><span id="line-1151"></span><span class="hs-comment">-- as soon as it finds that two types are not equal.</span><span>
</span><span id="line-1152"></span><span class="hs-comment">-- This is quite handy when some unification has made two</span><span>
</span><span id="line-1153"></span><span class="hs-comment">-- types in an inert Wanted to be equal. We can discover the equality without</span><span>
</span><span id="line-1154"></span><span class="hs-comment">-- flattening, which is sometimes very expensive (in the case of type functions).</span><span>
</span><span id="line-1155"></span><span class="hs-comment">-- In particular, this function makes a ~20% improvement in test case</span><span>
</span><span id="line-1156"></span><span class="hs-comment">-- perf/compiler/T5030.</span><span>
</span><span id="line-1157"></span><span class="hs-comment">--</span><span>
</span><span id="line-1158"></span><span class="hs-comment">-- Returns either the (partially zonked) types in the case of</span><span>
</span><span id="line-1159"></span><span class="hs-comment">-- inequality, or the one type in the case of equality. canEqReflexive is</span><span>
</span><span id="line-1160"></span><span class="hs-comment">-- a good next step in the 'Right' case. Returning 'Left' is always safe.</span><span>
</span><span id="line-1161"></span><span class="hs-comment">--</span><span>
</span><span id="line-1162"></span><span class="hs-comment">-- NB: This does *not* look through type synonyms. In fact, it treats type</span><span>
</span><span id="line-1163"></span><span class="hs-comment">-- synonyms as rigid constructors. In the future, it might be convenient</span><span>
</span><span id="line-1164"></span><span class="hs-comment">-- to look at only those arguments of type synonyms that actually appear</span><span>
</span><span id="line-1165"></span><span class="hs-comment">-- in the synonym RHS. But we're not there yet.</span><span>
</span><span id="line-1166"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#zonk_eq_types"><span class="hs-identifier hs-type">zonk_eq_types</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1167"></span><span id="zonk_eq_types"><span class="annot"><span class="annottext">zonk_eq_types :: TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="GHC.Tc.Solver.Canonical.html#zonk_eq_types"><span class="hs-identifier hs-var hs-var">zonk_eq_types</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span>
</span><span id="line-1168"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1169"></span><span>    </span><span id="local-6989586621681116393"><span class="annot"><span class="annottext">go :: TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681116373"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116373"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681116372"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116372"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVar -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116371"><span class="hs-identifier hs-var">tyvar_tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116373"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116372"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1170"></span><span>    </span><span class="annot"><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681116370"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116370"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681116369"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116369"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116368"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116370"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116369"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1171"></span><span>    </span><span class="annot"><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681116367"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116367"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681116366"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116366"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116368"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span>  </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116366"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116367"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1172"></span><span>
</span><span id="line-1173"></span><span>    </span><span class="hs-comment">-- We handle FunTys explicitly here despite the fact that they could also be</span><span>
</span><span id="line-1174"></span><span>    </span><span class="hs-comment">-- treated as an application. Why? Well, for one it's cheaper to just look</span><span>
</span><span id="line-1175"></span><span>    </span><span class="hs-comment">-- at two types (the argument and result types) than four (the argument,</span><span>
</span><span id="line-1176"></span><span>    </span><span class="hs-comment">-- result, and their RuntimeReps). Also, we haven't completely zonked yet,</span><span>
</span><span id="line-1177"></span><span>    </span><span class="hs-comment">-- so we may run into an unzonked type variable while trying to compute the</span><span>
</span><span id="line-1178"></span><span>    </span><span class="hs-comment">-- RuntimeReps of the argument and result types. This can be observed in</span><span>
</span><span id="line-1179"></span><span>    </span><span class="hs-comment">-- testcase tc269.</span><span>
</span><span id="line-1180"></span><span>    </span><span class="annot"><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681116365"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116365"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116364"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116364"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1181"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681116362"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116362"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span id="local-6989586621681116361"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116361"><span class="hs-identifier hs-var">arg1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116360"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116360"><span class="hs-identifier hs-var">res1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (Scaled TcType, TcType)
</span><a href="#local-6989586621681116359"><span class="hs-identifier hs-var">split1</span></a></span><span>
</span><span id="line-1182"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681116358"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116358"><span class="hs-identifier hs-var">w2</span></a></span></span><span> </span><span id="local-6989586621681116357"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116357"><span class="hs-identifier hs-var">arg2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116356"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116356"><span class="hs-identifier hs-var">res2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (Scaled TcType, TcType)
</span><a href="#local-6989586621681116355"><span class="hs-identifier hs-var">split2</span></a></span><span>
</span><span id="line-1183"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-identifier hs-var">eqType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116362"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116358"><span class="hs-identifier hs-var">w2</span></a></span><span>
</span><span id="line-1184"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116353"><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116353"><span class="hs-identifier hs-var">res_a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116361"><span class="hs-identifier hs-var">arg1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116357"><span class="hs-identifier hs-var">arg2</span></a></span><span>
</span><span id="line-1185"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116352"><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116352"><span class="hs-identifier hs-var">res_b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116360"><span class="hs-identifier hs-var">res1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116356"><span class="hs-identifier hs-var">res2</span></a></span><span>
</span><span id="line-1186"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType))
-&gt; Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcType -&gt; TcType)
-&gt; Either (Pair TcType) TcType
-&gt; Either (Pair TcType) TcType
-&gt; Either (Pair TcType) TcType
forall a b c.
(a -&gt; b -&gt; c)
-&gt; Either (Pair b) b -&gt; Either (Pair a) a -&gt; Either (Pair c) c
</span><a href="#local-6989586621681116351"><span class="hs-identifier hs-var">combine_rev</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTy"><span class="hs-identifier hs-var">mkVisFunTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116362"><span class="hs-identifier hs-var">w1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116352"><span class="hs-identifier hs-var">res_b</span></a></span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116353"><span class="hs-identifier hs-var">res_a</span></a></span><span>
</span><span id="line-1187"></span><span>           </span><span class="hs-special">}</span><span>
</span><span id="line-1188"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Maybe (Scaled TcType, TcType) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Scaled TcType, TcType)
</span><a href="#local-6989586621681116359"><span class="hs-identifier hs-var">split1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Maybe (Scaled TcType, TcType) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Scaled TcType, TcType)
</span><a href="#local-6989586621681116355"><span class="hs-identifier hs-var">split2</span></a></span><span>
</span><span id="line-1189"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
forall {m :: * -&gt; *} {a} {b}.
Monad m =&gt;
a -&gt; a -&gt; m (Either (Pair a) b)
</span><a href="#local-6989586621681116348"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116365"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116364"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1190"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1191"></span><span>        </span><span id="local-6989586621681116359"><span class="annot"><span class="annottext">split1 :: Maybe (Scaled TcType, TcType)
</span><a href="#local-6989586621681116359"><span class="hs-identifier hs-var hs-var">split1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (Scaled TcType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTy_maybe"><span class="hs-identifier hs-var">tcSplitFunTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116365"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1192"></span><span>        </span><span id="local-6989586621681116355"><span class="annot"><span class="annottext">split2 :: Maybe (Scaled TcType, TcType)
</span><a href="#local-6989586621681116355"><span class="hs-identifier hs-var hs-var">split2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (Scaled TcType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTy_maybe"><span class="hs-identifier hs-var">tcSplitFunTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116364"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1193"></span><span>
</span><span id="line-1194"></span><span>    </span><span class="annot"><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681116346"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116346"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116345"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116345"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1195"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116344"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116344"><span class="hs-identifier hs-var">tc1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116343"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116343"><span class="hs-identifier hs-var">tys1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; Maybe (TyCon, [TcType])
TcType -&gt; Maybe (TyCon, [TcType])
</span><a href="GHC.Core.Type.html#repSplitTyConApp_maybe"><span class="hs-identifier hs-var">repSplitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116346"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1196"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116341"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116341"><span class="hs-identifier hs-var">tc2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116340"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116340"><span class="hs-identifier hs-var">tys2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; Maybe (TyCon, [TcType])
TcType -&gt; Maybe (TyCon, [TcType])
</span><a href="GHC.Core.Type.html#repSplitTyConApp_maybe"><span class="hs-identifier hs-var">repSplitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116345"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1197"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116344"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116341"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116343"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType] -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-operator hs-var">`equalLength`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116340"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1198"></span><span>          </span><span class="hs-comment">-- Crucial to check for equal-length args, because</span><span>
</span><span id="line-1199"></span><span>          </span><span class="hs-comment">-- we cannot assume that the two args to 'go' have</span><span>
</span><span id="line-1200"></span><span>          </span><span class="hs-comment">-- the same kind.  E.g go (Proxy *      (Maybe Int))</span><span>
</span><span id="line-1201"></span><span>          </span><span class="hs-comment">--                        (Proxy (*-&gt;*) Maybe)</span><span>
</span><span id="line-1202"></span><span>          </span><span class="hs-comment">-- We'll call (go (Maybe Int) Maybe)</span><span>
</span><span id="line-1203"></span><span>          </span><span class="hs-comment">-- See #13083</span><span>
</span><span id="line-1204"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; [TcType] -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116339"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116344"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116343"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116340"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1205"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
forall {m :: * -&gt; *} {a} {b}.
Monad m =&gt;
a -&gt; a -&gt; m (Either (Pair a) b)
</span><a href="#local-6989586621681116348"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116346"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116345"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1206"></span><span>
</span><span id="line-1207"></span><span>    </span><span class="annot"><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681116338"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116338"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116337"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116337"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1208"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116336"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116336"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116335"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116335"><span class="hs-identifier hs-var">ty1b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType)
</span><a href="GHC.Core.Type.html#tcRepSplitAppTy_maybe"><span class="hs-identifier hs-var">tcRepSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116338"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1209"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116333"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116333"><span class="hs-identifier hs-var">ty2a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116332"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116332"><span class="hs-identifier hs-var">ty2b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType)
</span><a href="GHC.Core.Type.html#tcRepSplitAppTy_maybe"><span class="hs-identifier hs-var">tcRepSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116337"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1210"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116331"><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116331"><span class="hs-identifier hs-var">res_a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116336"><span class="hs-identifier hs-var">ty1a</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116333"><span class="hs-identifier hs-var">ty2a</span></a></span><span>
</span><span id="line-1211"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116330"><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116330"><span class="hs-identifier hs-var">res_b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116335"><span class="hs-identifier hs-var">ty1b</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116332"><span class="hs-identifier hs-var">ty2b</span></a></span><span>
</span><span id="line-1212"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType))
-&gt; Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcType -&gt; TcType)
-&gt; Either (Pair TcType) TcType
-&gt; Either (Pair TcType) TcType
-&gt; Either (Pair TcType) TcType
forall a b c.
(a -&gt; b -&gt; c)
-&gt; Either (Pair b) b -&gt; Either (Pair a) a -&gt; Either (Pair c) c
</span><a href="#local-6989586621681116351"><span class="hs-identifier hs-var">combine_rev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#mkAppTy"><span class="hs-identifier hs-var">mkAppTy</span></a></span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116330"><span class="hs-identifier hs-var">res_b</span></a></span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType
</span><a href="#local-6989586621681116331"><span class="hs-identifier hs-var">res_a</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1213"></span><span>
</span><span id="line-1214"></span><span>    </span><span class="annot"><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681116328"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681116328"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621681116327"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116327"><span class="hs-identifier hs-var">lit1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621681116326"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116326"><span class="hs-identifier hs-var">lit2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1215"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116327"><span class="hs-identifier hs-var">lit1</span></a></span><span> </span><span class="annot"><span class="annottext">TyLit -&gt; TyLit -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681116326"><span class="hs-identifier hs-var">lit2</span></a></span><span>
</span><span id="line-1216"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Either (Pair TcType) TcType
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116328"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1217"></span><span>
</span><span id="line-1218"></span><span>    </span><span class="annot"><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681116325"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116325"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116324"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116324"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
forall {m :: * -&gt; *} {a} {b}.
Monad m =&gt;
a -&gt; a -&gt; m (Either (Pair a) b)
</span><a href="#local-6989586621681116348"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116325"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116324"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1219"></span><span>      </span><span class="hs-comment">-- We don't handle more complex forms here</span><span>
</span><span id="line-1220"></span><span>
</span><span id="line-1221"></span><span>    </span><span id="local-6989586621681116348"><span class="annot"><span class="annottext">bale_out :: a -&gt; a -&gt; m (Either (Pair a) b)
</span><a href="#local-6989586621681116348"><span class="hs-identifier hs-var hs-var">bale_out</span></a></span></span><span> </span><span id="local-6989586621681116321"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116321"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116320"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116320"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either (Pair a) b -&gt; m (Either (Pair a) b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (Pair a) b -&gt; m (Either (Pair a) b))
-&gt; Either (Pair a) b -&gt; m (Either (Pair a) b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Pair a -&gt; Either (Pair a) b
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; a -&gt; Pair a
forall a. a -&gt; a -&gt; Pair a
</span><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-var">Pair</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116321"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116320"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1222"></span><span>
</span><span id="line-1223"></span><span>    </span><span class="annot"><a href="#local-6989586621681116368"><span class="hs-identifier hs-type">tyvar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-1224"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1225"></span><span>      </span><span class="hs-comment">-- Try to do as little as possible, as anything we do here is redundant</span><span>
</span><span id="line-1226"></span><span>      </span><span class="hs-comment">-- with flattening. In particular, no need to zonk kinds. That's why</span><span>
</span><span id="line-1227"></span><span>      </span><span class="hs-comment">-- we don't use the already-defined zonking functions</span><span>
</span><span id="line-1228"></span><span>    </span><span id="local-6989586621681116368"><span class="annot"><span class="annottext">tyvar :: SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116368"><span class="hs-identifier hs-var hs-var">tyvar</span></a></span></span><span> </span><span id="local-6989586621681116319"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116319"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681116318"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116318"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681116317"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116317"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-1229"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116318"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1230"></span><span>          </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: TcTyVarDetails -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116313"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681116313"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1231"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116312"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681116312"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcS MetaDetails
forall a. TcRef a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681116313"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-1232"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681116312"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1233"></span><span>                      </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcS (Either (Pair TcType) TcType)
forall {b}. TcS (Either (Pair TcType) b)
</span><a href="#local-6989586621681116309"><span class="hs-identifier hs-var">give_up</span></a></span><span>
</span><span id="line-1234"></span><span>                      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681116307"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116307"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType -&gt; TcS ()
forall {a} {a}. (Outputable a, Outputable a) =&gt; a -&gt; a -&gt; TcS ()
</span><a href="#local-6989586621681116306"><span class="hs-identifier hs-var">trace_indirect</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116318"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116307"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-1235"></span><span>                                         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">SwapFlag
-&gt; (TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType))
-&gt; TcType
-&gt; TcType
-&gt; TcS (Either (Pair TcType) TcType)
forall a b. SwapFlag -&gt; (a -&gt; a -&gt; b) -&gt; a -&gt; a -&gt; b
</span><a href="GHC.Types.Basic.html#unSwap"><span class="hs-identifier hs-var">unSwap</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116319"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116307"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116317"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1236"></span><span>          </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcS (Either (Pair TcType) TcType)
forall {b}. TcS (Either (Pair TcType) b)
</span><a href="#local-6989586621681116309"><span class="hs-identifier hs-var">give_up</span></a></span><span>
</span><span id="line-1237"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1238"></span><span>        </span><span id="local-6989586621681116309"><span class="annot"><span class="annottext">give_up :: TcS (Either (Pair TcType) b)
</span><a href="#local-6989586621681116309"><span class="hs-identifier hs-var hs-var">give_up</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) b -&gt; TcS (Either (Pair TcType) b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (Pair TcType) b -&gt; TcS (Either (Pair TcType) b))
-&gt; Either (Pair TcType) b -&gt; TcS (Either (Pair TcType) b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Pair TcType -&gt; Either (Pair TcType) b
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">(Pair TcType -&gt; Either (Pair TcType) b)
-&gt; Pair TcType -&gt; Either (Pair TcType) b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
-&gt; (TcType -&gt; TcType -&gt; Pair TcType)
-&gt; TcType
-&gt; TcType
-&gt; Pair TcType
forall a b. SwapFlag -&gt; (a -&gt; a -&gt; b) -&gt; a -&gt; a -&gt; b
</span><a href="GHC.Types.Basic.html#unSwap"><span class="hs-identifier hs-var">unSwap</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116319"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Pair TcType
forall a. a -&gt; a -&gt; Pair a
</span><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-var">Pair</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116318"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116317"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1239"></span><span>
</span><span id="line-1240"></span><span>    </span><span id="local-6989586621681116371"><span class="annot"><span class="annottext">tyvar_tyvar :: TcTyVar -&gt; TcTyVar -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116371"><span class="hs-identifier hs-var hs-var">tyvar_tyvar</span></a></span></span><span> </span><span id="local-6989586621681116303"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116303"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681116302"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116302"><span class="hs-identifier hs-var">tv2</span></a></span></span><span>
</span><span id="line-1241"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116303"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116302"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Either (Pair TcType) TcType
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116303"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1242"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116301"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116301"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116300"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116300"><span class="hs-identifier hs-var">progress1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS (TcType, Bool)
</span><a href="#local-6989586621681116299"><span class="hs-identifier hs-var">quick_zonk</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116303"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1243"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116298"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116298"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116297"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116297"><span class="hs-identifier hs-var">progress2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS (TcType, Bool)
</span><a href="#local-6989586621681116299"><span class="hs-identifier hs-var">quick_zonk</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116302"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1244"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116300"><span class="hs-identifier hs-var">progress1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116297"><span class="hs-identifier hs-var">progress2</span></a></span><span>
</span><span id="line-1245"></span><span>                          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116301"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116298"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-1246"></span><span>                          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType))
-&gt; Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Pair TcType -&gt; Either (Pair TcType) TcType
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Pair TcType
forall a. a -&gt; a -&gt; Pair a
</span><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-var">Pair</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116303"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116302"><span class="hs-identifier hs-var">tv2</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1247"></span><span>
</span><span id="line-1248"></span><span>    </span><span id="local-6989586621681116306"><span class="annot"><span class="annottext">trace_indirect :: a -&gt; a -&gt; TcS ()
</span><a href="#local-6989586621681116306"><span class="hs-identifier hs-var hs-var">trace_indirect</span></a></span></span><span> </span><span id="local-6989586621681116292"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116292"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681116291"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116291"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-1249"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Following filled tyvar (zonk_eq_types)&quot;</span></span><span>
</span><span id="line-1250"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116292"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#equals"><span class="hs-identifier hs-var">equals</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116291"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1251"></span><span>
</span><span id="line-1252"></span><span>    </span><span id="local-6989586621681116299"><span class="annot"><span class="annottext">quick_zonk :: TcTyVar -&gt; TcS (TcType, Bool)
</span><a href="#local-6989586621681116299"><span class="hs-identifier hs-var hs-var">quick_zonk</span></a></span></span><span> </span><span id="local-6989586621681116282"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116282"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116282"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1253"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: TcTyVarDetails -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116281"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681116281"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1254"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116280"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681116280"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcS MetaDetails
forall a. TcRef a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681116281"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-1255"></span><span>              </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681116280"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1256"></span><span>                  </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(TcType, Bool) -&gt; TcS (TcType, Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116282"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-1257"></span><span>                  </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681116279"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116279"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType -&gt; TcS ()
forall {a} {a}. (Outputable a, Outputable a) =&gt; a -&gt; a -&gt; TcS ()
</span><a href="#local-6989586621681116306"><span class="hs-identifier hs-var">trace_indirect</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116282"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116279"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-1258"></span><span>                                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcType, Bool) -&gt; TcS (TcType, Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116279"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1259"></span><span>      </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(TcType, Bool) -&gt; TcS (TcType, Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116282"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-1260"></span><span>
</span><span id="line-1261"></span><span>      </span><span class="hs-comment">-- This happens for type families, too. But recall that failure</span><span>
</span><span id="line-1262"></span><span>      </span><span class="hs-comment">-- here just means to try harder, so it's OK if the type function</span><span>
</span><span id="line-1263"></span><span>      </span><span class="hs-comment">-- isn't injective.</span><span>
</span><span id="line-1264"></span><span>    </span><span class="annot"><a href="#local-6989586621681116339"><span class="hs-identifier hs-type">tycon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1265"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1266"></span><span>    </span><span id="local-6989586621681116339"><span class="annot"><span class="annottext">tycon :: TyCon -&gt; [TcType] -&gt; [TcType] -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116339"><span class="hs-identifier hs-var hs-var">tycon</span></a></span></span><span> </span><span id="local-6989586621681116278"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116278"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681116277"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116277"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621681116276"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116276"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-1267"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116275"><span class="annot"><span class="annottext">[Either (Pair TcType) TcType]
</span><a href="#local-6989586621681116275"><span class="hs-identifier hs-var">results</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType))
-&gt; [TcType] -&gt; [TcType] -&gt; TcS [Either (Pair TcType) TcType]
forall (m :: * -&gt; *) a b c.
Applicative m =&gt;
(a -&gt; b -&gt; m c) -&gt; [a] -&gt; [b] -&gt; m [c]
</span><a href="../../base/src/Control.Monad.html#zipWithM"><span class="hs-identifier hs-var">zipWithM</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS (Either (Pair TcType) TcType)
</span><a href="#local-6989586621681116393"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116277"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116276"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1268"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType))
-&gt; Either (Pair TcType) TcType -&gt; TcS (Either (Pair TcType) TcType)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[Either (Pair TcType) TcType] -&gt; Either (Pair [TcType]) [TcType]
</span><a href="#local-6989586621681116273"><span class="hs-identifier hs-var">combine_results</span></a></span><span> </span><span class="annot"><span class="annottext">[Either (Pair TcType) TcType]
</span><a href="#local-6989586621681116275"><span class="hs-identifier hs-var">results</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1269"></span><span>               </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681116272"><span class="annot"><span class="annottext">Pair [TcType]
</span><a href="#local-6989586621681116272"><span class="hs-identifier hs-var">tys</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Pair TcType -&gt; Either (Pair TcType) TcType
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116278"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">([TcType] -&gt; TcType) -&gt; Pair [TcType] -&gt; Pair TcType
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Pair [TcType]
</span><a href="#local-6989586621681116272"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1270"></span><span>               </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681116269"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116269"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Either (Pair TcType) TcType
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116278"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116269"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1271"></span><span>
</span><span id="line-1272"></span><span>    </span><span class="annot"><a href="#local-6989586621681116273"><span class="hs-identifier hs-type">combine_results</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1273"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1274"></span><span>    </span><span id="local-6989586621681116273"><span class="annot"><span class="annottext">combine_results :: [Either (Pair TcType) TcType] -&gt; Either (Pair [TcType]) [TcType]
</span><a href="#local-6989586621681116273"><span class="hs-identifier hs-var hs-var">combine_results</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Pair [TcType] -&gt; Pair [TcType])
-&gt; ([TcType] -&gt; [TcType])
-&gt; Either (Pair [TcType]) [TcType]
-&gt; Either (Pair [TcType]) [TcType]
forall (p :: * -&gt; * -&gt; *) a b c d.
Bifunctor p =&gt;
(a -&gt; b) -&gt; (c -&gt; d) -&gt; p a c -&gt; p b d
</span><a href="../../base/src/Data.Bifunctor.html#bimap"><span class="hs-identifier hs-var">bimap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([TcType] -&gt; [TcType]) -&gt; Pair [TcType] -&gt; Pair [TcType]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">(Either (Pair [TcType]) [TcType]
 -&gt; Either (Pair [TcType]) [TcType])
-&gt; ([Either (Pair TcType) TcType]
    -&gt; Either (Pair [TcType]) [TcType])
-&gt; [Either (Pair TcType) TcType]
-&gt; Either (Pair [TcType]) [TcType]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-1275"></span><span>                      </span><span class="annot"><span class="annottext">(Either (Pair [TcType]) [TcType]
 -&gt; Either (Pair TcType) TcType -&gt; Either (Pair [TcType]) [TcType])
-&gt; Either (Pair [TcType]) [TcType]
-&gt; [Either (Pair TcType) TcType]
-&gt; Either (Pair [TcType]) [TcType]
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TcType -&gt; [TcType] -&gt; [TcType])
-&gt; Either (Pair [TcType]) [TcType]
-&gt; Either (Pair TcType) TcType
-&gt; Either (Pair [TcType]) [TcType]
forall a b c.
(a -&gt; b -&gt; c)
-&gt; Either (Pair b) b -&gt; Either (Pair a) a -&gt; Either (Pair c) c
</span><a href="#local-6989586621681116351"><span class="hs-identifier hs-var">combine_rev</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">:</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcType] -&gt; Either (Pair [TcType]) [TcType]
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1276"></span><span>
</span><span id="line-1277"></span><span>      </span><span class="hs-comment">-- combine (in reverse) a new result onto an already-combined result</span><span>
</span><span id="line-1278"></span><span>    </span><span id="local-6989586621681117432"><span id="local-6989586621681117433"><span id="local-6989586621681117434"><span class="annot"><a href="#local-6989586621681116351"><span class="hs-identifier hs-type">combine_rev</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681117434"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681117433"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681117432"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1279"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117433"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621681117433"><span class="hs-identifier hs-type">b</span></a></span><span>
</span><span id="line-1280"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117434"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621681117434"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-1281"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117432"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621681117432"><span class="hs-identifier hs-type">c</span></a></span></span></span></span><span>
</span><span id="line-1282"></span><span>    </span><span id="local-6989586621681116351"><span class="annot"><span class="annottext">combine_rev :: forall a b c.
(a -&gt; b -&gt; c)
-&gt; Either (Pair b) b -&gt; Either (Pair a) a -&gt; Either (Pair c) c
</span><a href="#local-6989586621681116351"><span class="hs-identifier hs-var hs-var">combine_rev</span></a></span></span><span> </span><span id="local-6989586621681116256"><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116256"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681116255"><span class="annot"><span class="annottext">Pair b
</span><a href="#local-6989586621681116255"><span class="hs-identifier hs-var">list</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681116254"><span class="annot"><span class="annottext">Pair a
</span><a href="#local-6989586621681116254"><span class="hs-identifier hs-var">elt</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Pair c -&gt; Either (Pair c) c
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116256"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; c) -&gt; Pair a -&gt; Pair (b -&gt; c)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Pair a
</span><a href="#local-6989586621681116254"><span class="hs-identifier hs-var">elt</span></a></span><span>     </span><span class="annot"><span class="annottext">Pair (b -&gt; c) -&gt; Pair b -&gt; Pair c
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Pair b
</span><a href="#local-6989586621681116255"><span class="hs-identifier hs-var">list</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1283"></span><span>    </span><span class="annot"><a href="#local-6989586621681116351"><span class="hs-identifier hs-var">combine_rev</span></a></span><span> </span><span id="local-6989586621681116253"><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116253"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681116252"><span class="annot"><span class="annottext">Pair b
</span><a href="#local-6989586621681116252"><span class="hs-identifier hs-var">list</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681116251"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116251"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Pair c -&gt; Either (Pair c) c
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116253"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; c) -&gt; Pair a -&gt; Pair (b -&gt; c)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Pair a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116251"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Pair (b -&gt; c) -&gt; Pair b -&gt; Pair c
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Pair b
</span><a href="#local-6989586621681116252"><span class="hs-identifier hs-var">list</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1284"></span><span>    </span><span class="annot"><a href="#local-6989586621681116351"><span class="hs-identifier hs-var">combine_rev</span></a></span><span> </span><span id="local-6989586621681116250"><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116250"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681116249"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681116249"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681116248"><span class="annot"><span class="annottext">Pair a
</span><a href="#local-6989586621681116248"><span class="hs-identifier hs-var">elt</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Pair c -&gt; Either (Pair c) c
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116250"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; c) -&gt; Pair a -&gt; Pair (b -&gt; c)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Pair a
</span><a href="#local-6989586621681116248"><span class="hs-identifier hs-var">elt</span></a></span><span>     </span><span class="annot"><span class="annottext">Pair (b -&gt; c) -&gt; Pair b -&gt; Pair c
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; Pair b
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681116249"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1285"></span><span>    </span><span class="annot"><a href="#local-6989586621681116351"><span class="hs-identifier hs-var">combine_rev</span></a></span><span> </span><span id="local-6989586621681116247"><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116247"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681116246"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681116246"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681116245"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116245"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">c -&gt; Either (Pair c) c
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621681116247"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681116245"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681116246"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1286"></span><span>
</span><span id="line-1287"></span><span class="hs-comment">{- See Note [Unwrap newtypes first]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  newtype N m a = MkN (m a)
Then N will get a conservative, Nominal role for its second parameter 'a',
because it appears as an argument to the unknown 'm'. Now consider
  [W] N Maybe a  ~R#  N Maybe b

If we decompose, we'll get
  [W] a ~N# b

But if instead we unwrap we'll get
  [W] Maybe a ~R# Maybe b
which in turn gives us
  [W] a ~R# b
which is easier to satisfy.

Bottom line: unwrap newtypes before decomposing them!
c.f. #9123 comment:52,53 for a compelling example.

Note [Newtypes can blow the stack]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have

  newtype X = MkX (Int -&gt; X)
  newtype Y = MkY (Int -&gt; Y)

and now wish to prove

  [W] X ~R Y

This Wanted will loop, expanding out the newtypes ever deeper looking
for a solid match or a solid discrepancy. Indeed, there is something
appropriate to this looping, because X and Y *do* have the same representation,
in the limit -- they're both (Fix ((-&gt;) Int)). However, no finitely-sized
coercion will ever witness it. This loop won't actually cause GHC to hang,
though, because we check our depth when unwrapping newtypes.

Note [Eager reflexivity check]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have

  newtype X = MkX (Int -&gt; X)

and

  [W] X ~R X

Naively, we would start unwrapping X and end up in a loop. Instead,
we do this eager reflexivity check. This is necessary only for representational
equality because the flattener technology deals with the similar case
(recursive type families) for nominal equality.

Note that this check does not catch all cases, but it will catch the cases
we're most worried about, types like X above that are actually inhabited.

Here's another place where this reflexivity check is key:
Consider trying to prove (f a) ~R (f a). The AppTys in there can't
be decomposed, because representational equality isn't congruent with respect
to AppTy. So, when canonicalising the equality above, we get stuck and
would normally produce a CIrredCan. However, we really do want to
be able to solve (f a) ~R (f a). So, in the representational case only,
we do a reflexivity check.

(This would be sound in the nominal case, but unnecessary, and I [Richard
E.] am worried that it would slow down the common case.)
-}</span><span>
</span><span id="line-1354"></span><span>
</span><span id="line-1355"></span><span class="hs-comment">------------------------</span><span>
</span><span id="line-1356"></span><span class="hs-comment">-- | We're able to unwrap a newtype. Update the bits accordingly.</span><span>
</span><span id="line-1357"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_newtype_nc"><span class="hs-identifier hs-type">can_eq_newtype_nc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>           </span><span class="hs-comment">-- ^ :: ty1 ~ ty2</span><span>
</span><span id="line-1358"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-1359"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>                                    </span><span class="hs-comment">-- ^ ty1</span><span>
</span><span id="line-1360"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- ^ :: ty1 ~ ty1'</span><span>
</span><span id="line-1361"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>               </span><span class="hs-comment">-- ^ ty2</span><span>
</span><span id="line-1362"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>               </span><span class="hs-comment">-- ^ ty2, with type synonyms</span><span>
</span><span id="line-1363"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1364"></span><span id="can_eq_newtype_nc"><span class="annot"><span class="annottext">can_eq_newtype_nc :: CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; ((Bag GlobalRdrElt, TcCoercion), TcType)
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_newtype_nc"><span class="hs-identifier hs-var hs-var">can_eq_newtype_nc</span></a></span></span><span> </span><span id="local-6989586621681116244"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116244"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116243"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116243"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681116242"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116242"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681116241"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681116241"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116240"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116240"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116239"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116239"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681116238"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116238"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116237"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116237"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-1365"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;can_eq_newtype_nc&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1366"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116244"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SwapFlag -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116243"><span class="hs-identifier hs-var">swapped</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116240"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681116241"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116239"><span class="hs-identifier hs-var">ty1'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116238"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1367"></span><span>
</span><span id="line-1368"></span><span>         </span><span class="hs-comment">-- check for blowing our stack:</span><span>
</span><span id="line-1369"></span><span>         </span><span class="hs-comment">-- See Note [Newtypes can blow the stack]</span><span>
</span><span id="line-1370"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#checkReductionDepth"><span class="hs-identifier hs-var">checkReductionDepth</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116244"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116242"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1371"></span><span>
</span><span id="line-1372"></span><span>         </span><span class="hs-comment">-- Next, we record uses of newtype constructors, since coercing</span><span>
</span><span id="line-1373"></span><span>         </span><span class="hs-comment">-- through newtypes is tantamount to using their constructors.</span><span>
</span><span id="line-1374"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#addUsedGREs"><span class="hs-identifier hs-var">addUsedGREs</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681116234"><span class="hs-identifier hs-var">gre_list</span></a></span><span>
</span><span id="line-1375"></span><span>         </span><span class="hs-comment">-- If a newtype constructor was imported, don't warn about not</span><span>
</span><span id="line-1376"></span><span>         </span><span class="hs-comment">-- importing it...</span><span>
</span><span id="line-1377"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; TcS ()) -&gt; [Name] -&gt; TcS ()
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Foldable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f ()
</span><a href="../../base/src/Data.Foldable.html#traverse_"><span class="hs-identifier hs-var">traverse_</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#keepAlive"><span class="hs-identifier hs-var">keepAlive</span></a></span><span> </span><span class="annot"><span class="annottext">([Name] -&gt; TcS ()) -&gt; [Name] -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Name) -&gt; [GlobalRdrElt] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681116234"><span class="hs-identifier hs-var">gre_list</span></a></span><span>
</span><span id="line-1378"></span><span>         </span><span class="hs-comment">-- ...and similarly, if a newtype constructor was defined in the same</span><span>
</span><span id="line-1379"></span><span>         </span><span class="hs-comment">-- module, don't warn about it being unused.</span><span>
</span><span id="line-1380"></span><span>         </span><span class="hs-comment">-- See Note [Tracking unused binding and imports] in GHC.Tc.Utils.</span><span>
</span><span id="line-1381"></span><span>
</span><span id="line-1382"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116231"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116231"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116244"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116243"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116239"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116237"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-1383"></span><span>                                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116240"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116237"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1384"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc"><span class="hs-identifier hs-var">can_eq_nc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116231"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116239"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116239"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116238"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116237"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1385"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1386"></span><span>    </span><span id="local-6989586621681116234"><span class="annot"><span class="annottext">gre_list :: [GlobalRdrElt]
</span><a href="#local-6989586621681116234"><span class="hs-identifier hs-var hs-var">gre_list</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt -&gt; [GlobalRdrElt]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681116241"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-1387"></span><span>
</span><span id="line-1388"></span><span class="hs-comment">---------</span><span>
</span><span id="line-1389"></span><span class="hs-comment">-- ^ Decompose a type application.</span><span>
</span><span id="line-1390"></span><span class="hs-comment">-- All input types must be flat. See Note [Canonicalising type applications]</span><span>
</span><span id="line-1391"></span><span class="hs-comment">-- Nominal equality only!</span><span>
</span><span id="line-1392"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#can_eq_app"><span class="hs-identifier hs-type">can_eq_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>       </span><span class="hs-comment">-- :: s1 t1 ~N s2 t2</span><span>
</span><span id="line-1393"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Xi"><span class="hs-identifier hs-type">Xi</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Xi"><span class="hs-identifier hs-type">Xi</span></a></span><span>         </span><span class="hs-comment">-- s1 t1</span><span>
</span><span id="line-1394"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Xi"><span class="hs-identifier hs-type">Xi</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Xi"><span class="hs-identifier hs-type">Xi</span></a></span><span>         </span><span class="hs-comment">-- s2 t2</span><span>
</span><span id="line-1395"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1396"></span><span>
</span><span id="line-1397"></span><span class="hs-comment">-- AppTys only decompose for nominal equality, so this case just leads</span><span>
</span><span id="line-1398"></span><span class="hs-comment">-- to an irreducible constraint; see typecheck/should_compile/T10494</span><span>
</span><span id="line-1399"></span><span class="hs-comment">-- See Note [Decomposing equality], note {4}</span><span>
</span><span id="line-1400"></span><span id="can_eq_app"><span class="annot"><span class="annottext">can_eq_app :: CtEvidence
-&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_app"><span class="hs-identifier hs-var hs-var">can_eq_app</span></a></span></span><span> </span><span id="local-6989586621681116226"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116225"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621681116224"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116224"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681116223"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116223"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span id="local-6989586621681116222"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116222"><span class="hs-identifier hs-var">t2</span></a></span></span><span>
</span><span id="line-1401"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtDerived"><span class="hs-identifier hs-type">CtDerived</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1402"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [Role] -&gt; [TcType] -&gt; [TcType] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unifyDeriveds"><span class="hs-identifier hs-var">unifyDeriveds</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116219"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116224"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116223"><span class="hs-identifier hs-var">s2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116222"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1403"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Decomposed [D] AppTy&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1404"></span><span>
</span><span id="line-1405"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116218"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116218"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1406"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116217"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116217"><span class="hs-identifier hs-var">co_s</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116219"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116223"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1407"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116215"><span class="annot"><span class="annottext">arg_loc :: CtLoc
</span><a href="#local-6989586621681116215"><span class="hs-identifier hs-var hs-var">arg_loc</span></a></span></span><span>
</span><span id="line-1408"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isNextArgVisible"><span class="hs-identifier hs-var">isNextArgVisible</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116219"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-1409"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (CtOrigin -&gt; CtOrigin) -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#updateCtLocOrigin"><span class="hs-identifier hs-var">updateCtLocOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116219"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#toInvisibleOrigin"><span class="hs-identifier hs-var">toInvisibleOrigin</span></a></span><span>
</span><span id="line-1410"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116211"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116211"><span class="hs-identifier hs-var">co_t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116215"><span class="hs-identifier hs-var">arg_loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116224"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116222"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1411"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116210"><span class="annot"><span class="annottext">co :: TcCoercion
</span><a href="#local-6989586621681116210"><span class="hs-identifier hs-var hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkAppCo"><span class="hs-identifier hs-var">mkAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116217"><span class="hs-identifier hs-var">co_s</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116211"><span class="hs-identifier hs-var">co_t</span></a></span><span>
</span><span id="line-1412"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcEvDest -&gt; TcCoercion -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setWantedEq"><span class="hs-identifier hs-var">setWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116218"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116210"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1413"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Decomposed [W] AppTy&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1414"></span><span>
</span><span id="line-1415"></span><span>    </span><span class="hs-comment">-- If there is a ForAll/(-&gt;) mismatch, the use of the Left coercion</span><span>
</span><span id="line-1416"></span><span>    </span><span class="hs-comment">-- below is ill-typed, potentially leading to a panic in splitTyConApp</span><span>
</span><span id="line-1417"></span><span>    </span><span class="hs-comment">-- Test case: typecheck/should_run/Typeable1</span><span>
</span><span id="line-1418"></span><span>    </span><span class="hs-comment">-- We could also include this mismatch check above (for W and D), but it's slow</span><span>
</span><span id="line-1419"></span><span>    </span><span class="hs-comment">-- and we'll get a better error message not doing it</span><span>
</span><span id="line-1420"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116208"><span class="hs-identifier hs-var">s1k</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Bool
</span><a href="#local-6989586621681116207"><span class="hs-operator hs-var">`mismatches`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116206"><span class="hs-identifier hs-var">s2k</span></a></span><span>
</span><span id="line-1421"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqHardFailure"><span class="hs-identifier hs-var">canEqHardFailure</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#mkAppTy"><span class="hs-operator hs-var">`mkAppTy`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116224"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116223"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#mkAppTy"><span class="hs-operator hs-var">`mkAppTy`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116222"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1422"></span><span>
</span><span id="line-1423"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtGiven"><span class="hs-identifier hs-type">CtGiven</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_evar :: CtEvidence -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctev_evar"><span class="hs-identifier hs-var">ctev_evar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116205"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116205"><span class="hs-identifier hs-var">evar</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1424"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116204"><span class="annot"><span class="annottext">co :: TcCoercion
</span><a href="#local-6989586621681116204"><span class="hs-identifier hs-var hs-var">co</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcCoVarCo"><span class="hs-identifier hs-var">mkTcCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116205"><span class="hs-identifier hs-var">evar</span></a></span><span>
</span><span id="line-1425"></span><span>             </span><span id="local-6989586621681116202"><span class="annot"><span class="annottext">co_s :: TcCoercion
</span><a href="#local-6989586621681116202"><span class="hs-identifier hs-var hs-var">co_s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LeftOrRight -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcLRCo"><span class="hs-identifier hs-var">mkTcLRCo</span></a></span><span> </span><span class="annot"><span class="annottext">LeftOrRight
</span><a href="GHC.Types.Basic.html#CLeft"><span class="hs-identifier hs-var">CLeft</span></a></span><span>  </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116204"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1426"></span><span>             </span><span id="local-6989586621681116199"><span class="annot"><span class="annottext">co_t :: TcCoercion
</span><a href="#local-6989586621681116199"><span class="hs-identifier hs-var hs-var">co_t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LeftOrRight -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcLRCo"><span class="hs-identifier hs-var">mkTcLRCo</span></a></span><span> </span><span class="annot"><span class="annottext">LeftOrRight
</span><a href="GHC.Types.Basic.html#CRight"><span class="hs-identifier hs-var">CRight</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116204"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1427"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116197"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116197"><span class="hs-identifier hs-var">evar_s</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (TcType, EvTerm) -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newGivenEvVar"><span class="hs-identifier hs-var">newGivenEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116219"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#mkTcEqPredLikeEv"><span class="hs-identifier hs-var">mkTcEqPredLikeEv</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116223"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1428"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116202"><span class="hs-identifier hs-var">co_s</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1429"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116195"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116195"><span class="hs-identifier hs-var">evar_t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (TcType, EvTerm) -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newGivenEvVar"><span class="hs-identifier hs-var">newGivenEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116219"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#mkTcEqPredLikeEv"><span class="hs-identifier hs-var">mkTcEqPredLikeEv</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116224"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116222"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1430"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116199"><span class="hs-identifier hs-var">co_t</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1431"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[CtEvidence] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#emitWorkNC"><span class="hs-identifier hs-var">emitWorkNC</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116195"><span class="hs-identifier hs-var">evar_t</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1432"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqNC"><span class="hs-identifier hs-var">canEqNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116197"><span class="hs-identifier hs-var">evar_s</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#NomEq"><span class="hs-identifier hs-var">NomEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116223"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1433"></span><span>
</span><span id="line-1434"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1435"></span><span>    </span><span id="local-6989586621681116219"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681116219"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116226"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1436"></span><span>
</span><span id="line-1437"></span><span>    </span><span id="local-6989586621681116208"><span class="annot"><span class="annottext">s1k :: TcType
</span><a href="#local-6989586621681116208"><span class="hs-identifier hs-var hs-var">s1k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116225"><span class="hs-identifier hs-var">s1</span></a></span><span>
</span><span id="line-1438"></span><span>    </span><span id="local-6989586621681116206"><span class="annot"><span class="annottext">s2k :: TcType
</span><a href="#local-6989586621681116206"><span class="hs-identifier hs-var hs-var">s2k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116223"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1439"></span><span>
</span><span id="line-1440"></span><span>    </span><span id="local-6989586621681116190"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116190"><span class="hs-identifier hs-var">k1</span></a></span></span><span> </span><span id="local-6989586621681116207"><span class="annot"><span class="annottext">mismatches :: TcType -&gt; TcType -&gt; Bool
</span><a href="#local-6989586621681116207"><span class="hs-operator hs-var hs-var">`mismatches`</span></a></span></span><span> </span><span id="local-6989586621681116189"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116189"><span class="hs-identifier hs-var">k2</span></a></span></span><span>
</span><span id="line-1441"></span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isForAllTy"><span class="hs-identifier hs-var">isForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116190"><span class="hs-identifier hs-var">k1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isForAllTy"><span class="hs-identifier hs-var">isForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116189"><span class="hs-identifier hs-var">k2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1442"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isForAllTy"><span class="hs-identifier hs-var">isForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116190"><span class="hs-identifier hs-var">k1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isForAllTy"><span class="hs-identifier hs-var">isForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116189"><span class="hs-identifier hs-var">k2</span></a></span><span>
</span><span id="line-1443"></span><span>
</span><span id="line-1444"></span><span class="hs-comment">-----------------------</span><span>
</span><span id="line-1445"></span><span class="hs-comment">-- | Break apart an equality over a casted type</span><span>
</span><span id="line-1446"></span><span class="hs-comment">-- looking like   (ty1 |&gt; co1) ~ ty2   (modulo a swap-flag)</span><span>
</span><span id="line-1447"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqCast"><span class="hs-identifier hs-type">canEqCast</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>         </span><span class="hs-comment">-- are both types flat?</span><span>
</span><span id="line-1448"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-1449"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-1450"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-1451"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>   </span><span class="hs-comment">-- LHS (res. RHS), ty1 |&gt; co1</span><span>
</span><span id="line-1452"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>     </span><span class="hs-comment">-- RHS (res. LHS), ty2 both normal and pretty</span><span>
</span><span id="line-1453"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1454"></span><span id="canEqCast"><span class="annot"><span class="annottext">canEqCast :: Bool
-&gt; CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcType
-&gt; TcCoercion
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqCast"><span class="hs-identifier hs-var hs-var">canEqCast</span></a></span></span><span> </span><span id="local-6989586621681116186"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116186"><span class="hs-identifier hs-var">flat</span></a></span></span><span> </span><span id="local-6989586621681116185"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116185"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116184"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116184"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116183"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116183"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681116182"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116182"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116181"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116181"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621681116180"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116180"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621681116179"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116179"><span class="hs-identifier hs-var">ps_ty2</span></a></span></span><span>
</span><span id="line-1455"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Decomposing cast&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116185"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1456"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116182"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;|&gt;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116181"><span class="hs-identifier hs-var">co1</span></a></span><span>
</span><span id="line-1457"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116179"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1458"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116178"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116178"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116185"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116183"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116182"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116179"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span>
</span><span id="line-1459"></span><span>                                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcGReflRightCo"><span class="hs-identifier hs-var">mkTcGReflRightCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116176"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116182"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116181"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1460"></span><span>                                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116176"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116179"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1461"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; CtEvidence
-&gt; EqRel
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#can_eq_nc"><span class="hs-identifier hs-var">can_eq_nc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681116186"><span class="hs-identifier hs-var">flat</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116178"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116184"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116182"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116182"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116180"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116179"><span class="hs-identifier hs-var">ps_ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1462"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1463"></span><span>    </span><span id="local-6989586621681116176"><span class="annot"><span class="annottext">role :: Role
</span><a href="#local-6989586621681116176"><span class="hs-keyword hs-var hs-var">role</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116184"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-1464"></span><span>
</span><span id="line-1465"></span><span class="hs-comment">------------------------</span><span>
</span><span id="line-1466"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canTyConApp"><span class="hs-identifier hs-type">canTyConApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-1467"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1468"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1469"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1470"></span><span class="hs-comment">-- See Note [Decomposing TyConApps]</span><span>
</span><span id="line-1471"></span><span class="hs-comment">-- Neither tc1 nor tc2 is a saturated funTyCon</span><span>
</span><span id="line-1472"></span><span id="canTyConApp"><span class="annot"><span class="annottext">canTyConApp :: CtEvidence
-&gt; EqRel
-&gt; TyCon
-&gt; [TcType]
-&gt; TyCon
-&gt; [TcType]
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canTyConApp"><span class="hs-identifier hs-var hs-var">canTyConApp</span></a></span></span><span> </span><span id="local-6989586621681116175"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116174"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116174"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116173"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621681116172"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116172"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621681116171"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116171"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621681116170"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116170"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-1473"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116171"><span class="hs-identifier hs-var">tc2</span></a></span><span>
</span><span id="line-1474"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116172"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType] -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-operator hs-var">`equalLength`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116170"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1475"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116169"><span class="annot"><span class="annottext">InertSet
</span><a href="#local-6989586621681116169"><span class="hs-identifier hs-var">inerts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS InertSet
</span><a href="GHC.Tc.Solver.Monad.html#getTcSInerts"><span class="hs-identifier hs-var">getTcSInerts</span></a></span><span>
</span><span id="line-1476"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">InertSet -&gt; Bool
</span><a href="#local-6989586621681116167"><span class="hs-identifier hs-var">can_decompose</span></a></span><span> </span><span class="annot"><span class="annottext">InertSet
</span><a href="#local-6989586621681116169"><span class="hs-identifier hs-var">inerts</span></a></span><span>
</span><span id="line-1477"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; TyCon
-&gt; [TcType]
-&gt; [TcType]
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canDecomposableTyConAppOK"><span class="hs-identifier hs-var">canDecomposableTyConAppOK</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116174"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116172"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116170"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1478"></span><span>         </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqFailure"><span class="hs-identifier hs-var">canEqFailure</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116174"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116165"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116164"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1479"></span><span>
</span><span id="line-1480"></span><span>  </span><span class="hs-comment">-- See Note [Skolem abstract data] (at tyConSkolem)</span><span>
</span><span id="line-1481"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#tyConSkolem"><span class="hs-identifier hs-var">tyConSkolem</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#tyConSkolem"><span class="hs-identifier hs-var">tyConSkolem</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116171"><span class="hs-identifier hs-var">tc2</span></a></span><span>
</span><span id="line-1482"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canTyConApp: skolem abstract&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116171"><span class="hs-identifier hs-var">tc2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1483"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkIrredCt"><span class="hs-identifier hs-var">mkIrredCt</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#OtherCIS"><span class="hs-identifier hs-var">OtherCIS</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1484"></span><span>
</span><span id="line-1485"></span><span>  </span><span class="hs-comment">-- Fail straight away for better error messages</span><span>
</span><span id="line-1486"></span><span>  </span><span class="hs-comment">-- See Note [Use canEqFailure in canDecomposableTyConApp]</span><span>
</span><span id="line-1487"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116174"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; EqRel -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isGenerativeTyCon"><span class="hs-identifier hs-var">isGenerativeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-1488"></span><span>                             </span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isGenerativeTyCon"><span class="hs-identifier hs-var">isGenerativeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116171"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1489"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqFailure"><span class="hs-identifier hs-var">canEqFailure</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116174"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116165"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116164"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1490"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1491"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqHardFailure"><span class="hs-identifier hs-var">canEqHardFailure</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116165"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116164"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1492"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1493"></span><span>    </span><span class="hs-comment">-- Reconstruct the types for error messages. This would do</span><span>
</span><span id="line-1494"></span><span>    </span><span class="hs-comment">-- the wrong thing (from a pretty printing point of view)</span><span>
</span><span id="line-1495"></span><span>    </span><span class="hs-comment">-- for functions, because we've lost the AnonArgFlag; but</span><span>
</span><span id="line-1496"></span><span>    </span><span class="hs-comment">-- in fact we never call canTyConApp on a saturated FunTyCon</span><span>
</span><span id="line-1497"></span><span>    </span><span id="local-6989586621681116165"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681116165"><span class="hs-identifier hs-var hs-var">ty1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116172"><span class="hs-identifier hs-var">tys1</span></a></span><span>
</span><span id="line-1498"></span><span>    </span><span id="local-6989586621681116164"><span class="annot"><span class="annottext">ty2 :: TcType
</span><a href="#local-6989586621681116164"><span class="hs-identifier hs-var hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116171"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116170"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1499"></span><span>
</span><span id="line-1500"></span><span>    </span><span id="local-6989586621681116161"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681116161"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1501"></span><span>    </span><span id="local-6989586621681116160"><span class="annot"><span class="annottext">pred :: TcType
</span><a href="#local-6989586621681116160"><span class="hs-identifier hs-var hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1502"></span><span>
</span><span id="line-1503"></span><span>     </span><span class="hs-comment">-- See Note [Decomposing equality]</span><span>
</span><span id="line-1504"></span><span>    </span><span id="local-6989586621681116167"><span class="annot"><span class="annottext">can_decompose :: InertSet -&gt; Bool
</span><a href="#local-6989586621681116167"><span class="hs-identifier hs-var hs-var">can_decompose</span></a></span></span><span> </span><span id="local-6989586621681116157"><span class="annot"><span class="annottext">InertSet
</span><a href="#local-6989586621681116157"><span class="hs-identifier hs-var">inerts</span></a></span></span><span>
</span><span id="line-1505"></span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isInjectiveTyCon"><span class="hs-identifier hs-var">isInjectiveTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116173"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116174"><span class="hs-identifier hs-var">eq_rel</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1506"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; CtFlavour
</span><a href="GHC.Tc.Types.Constraint.html#ctEvFlavour"><span class="hs-identifier hs-var">ctEvFlavour</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116175"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">CtFlavour -&gt; CtFlavour -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">CtFlavour
</span><a href="GHC.Tc.Types.Constraint.html#Given"><span class="hs-identifier hs-var">Given</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bag Ct -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; TcType -&gt; InertSet -&gt; Bag Ct
</span><a href="GHC.Tc.Solver.Monad.html#matchableGivens"><span class="hs-identifier hs-var">matchableGivens</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116161"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116160"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">InertSet
</span><a href="#local-6989586621681116157"><span class="hs-identifier hs-var">inerts</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1507"></span><span>
</span><span id="line-1508"></span><span class="hs-comment">{-
Note [Use canEqFailure in canDecomposableTyConApp]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We must use canEqFailure, not canEqHardFailure here, because there is
the possibility of success if working with a representational equality.
Here is one case:

  type family TF a where TF Char = Bool
  data family DF a
  newtype instance DF Bool = MkDF Int

Suppose we are canonicalising (Int ~R DF (TF a)), where we don't yet
know `a`. This is *not* a hard failure, because we might soon learn
that `a` is, in fact, Char, and then the equality succeeds.

Here is another case:

  [G] Age ~R Int

where Age's constructor is not in scope. We don't want to report
an &quot;inaccessible code&quot; error in the context of this Given!

For example, see typecheck/should_compile/T10493, repeated here:

  import Data.Ord (Down)  -- no constructor

  foo :: Coercible (Down Int) Int =&gt; Down Int -&gt; Int
  foo = coerce

That should compile, but only because we use canEqFailure and not
canEqHardFailure.

Note [Decomposing equality]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we have a constraint (of any flavour and role) that looks like
T tys1 ~ T tys2, what can we conclude about tys1 and tys2? The answer,
of course, is &quot;it depends&quot;. This Note spells it all out.

In this Note, &quot;decomposition&quot; refers to taking the constraint
  [fl] (T tys1 ~X T tys2)
(for some flavour fl and some role X) and replacing it with
  [fls'] (tys1 ~Xs' tys2)
where that notation indicates a list of new constraints, where the
new constraints may have different flavours and different roles.

The key property to consider is injectivity. When decomposing a Given the
decomposition is sound if and only if T is injective in all of its type
arguments. When decomposing a Wanted, the decomposition is sound (assuming the
correct roles in the produced equality constraints), but it may be a guess --
that is, an unforced decision by the constraint solver. Decomposing Wanteds
over injective TyCons does not entail guessing. But sometimes we want to
decompose a Wanted even when the TyCon involved is not injective! (See below.)

So, in broad strokes, we want this rule:

(*) Decompose a constraint (T tys1 ~X T tys2) if and only if T is injective
at role X.

Pursuing the details requires exploring three axes:
* Flavour: Given vs. Derived vs. Wanted
* Role: Nominal vs. Representational
* TyCon species: datatype vs. newtype vs. data family vs. type family vs. type variable

(So a type variable isn't a TyCon, but it's convenient to put the AppTy case
in the same table.)

Right away, we can say that Derived behaves just as Wanted for the purposes
of decomposition. The difference between Derived and Wanted is the handling of
evidence. Since decomposition in these cases isn't a matter of soundness but of
guessing, we want the same behavior regardless of evidence.

Here is a table (discussion following) detailing where decomposition of
   (T s1 ... sn) ~r (T t1 .. tn)
is allowed.  The first four lines (Data types ... type family) refer
to TyConApps with various TyCons T; the last line is for AppTy, where
there is presumably a type variable at the head, so it's actually
   (s s1 ... sn) ~r (t t1 .. tn)

NOMINAL               GIVEN                       WANTED

Datatype               YES                         YES
Newtype                YES                         YES
Data family            YES                         YES
Type family            YES, in injective args{1}   YES, in injective args{1}
Type variable          YES                         YES

REPRESENTATIONAL      GIVEN                       WANTED

Datatype               YES                         YES
Newtype                NO{2}                      MAYBE{2}
Data family            NO{3}                      MAYBE{3}
Type family             NO                          NO
Type variable          NO{4}                       NO{4}

{1}: Type families can be injective in some, but not all, of their arguments,
so we want to do partial decomposition. This is quite different than the way
other decomposition is done, where the decomposed equalities replace the original
one. We thus proceed much like we do with superclasses: emitting new Givens
when &quot;decomposing&quot; a partially-injective type family Given and new Deriveds
when &quot;decomposing&quot; a partially-injective type family Wanted. (As of the time of
writing, 13 June 2015, the implementation of injective type families has not
been merged, but it should be soon. Please delete this parenthetical if the
implementation is indeed merged.)

{2}: See Note [Decomposing newtypes at representational role]

{3}: Because of the possibility of newtype instances, we must treat
data families like newtypes. See also Note [Decomposing newtypes at
representational role]. See #10534 and test case
typecheck/should_fail/T10534.

{4}: Because type variables can stand in for newtypes, we conservatively do not
decompose AppTys over representational equality.

In the implementation of can_eq_nc and friends, we don't directly pattern
match using lines like in the tables above, as those tables don't cover
all cases (what about PrimTyCon? tuples?). Instead we just ask about injectivity,
boiling the tables above down to rule (*). The exceptions to rule (*) are for
injective type families, which are handled separately from other decompositions,
and the MAYBE entries above.

Note [Decomposing newtypes at representational role]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This note discusses the 'newtype' line in the REPRESENTATIONAL table
in Note [Decomposing equality]. (At nominal role, newtypes are fully
decomposable.)

Here is a representative example of why representational equality over
newtypes is tricky:

  newtype Nt a = Mk Bool         -- NB: a is not used in the RHS,
  type role Nt representational  -- but the user gives it an R role anyway

If we have [W] Nt alpha ~R Nt beta, we *don't* want to decompose to
[W] alpha ~R beta, because it's possible that alpha and beta aren't
representationally equal. Here's another example.

  newtype Nt a = MkNt (Id a)
  type family Id a where Id a = a

  [W] Nt Int ~R Nt Age

Because of its use of a type family, Nt's parameter will get inferred to have
a nominal role. Thus, decomposing the wanted will yield [W] Int ~N Age, which
is unsatisfiable. Unwrapping, though, leads to a solution.

Conclusion:
 * Unwrap newtypes before attempting to decompose them.
   This is done in can_eq_nc'.

It all comes from the fact that newtypes aren't necessarily injective
w.r.t. representational equality.

Furthermore, as explained in Note [NthCo and newtypes] in GHC.Core.TyCo.Rep, we can't use
NthCo on representational coercions over newtypes. NthCo comes into play
only when decomposing givens.

Conclusion:
 * Do not decompose [G] N s ~R N t

Is it sensible to decompose *Wanted* constraints over newtypes?  Yes!
It's the only way we could ever prove (IO Int ~R IO Age), recalling
that IO is a newtype.

However we must be careful.  Consider

  type role Nt representational

  [G] Nt a ~R Nt b       (1)
  [W] NT alpha ~R Nt b   (2)
  [W] alpha ~ a          (3)

If we focus on (3) first, we'll substitute in (2), and now it's
identical to the given (1), so we succeed.  But if we focus on (2)
first, and decompose it, we'll get (alpha ~R b), which is not soluble.
This is exactly like the question of overlapping Givens for class
constraints: see Note [Instance and Given overlap] in GHC.Tc.Solver.Interact.

Conclusion:
  * Decompose [W] N s ~R N t  iff there no given constraint that could
    later solve it.

-}</span><span>
</span><span id="line-1691"></span><span>
</span><span id="line-1692"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canDecomposableTyConAppOK"><span class="hs-identifier hs-type">canDecomposableTyConAppOK</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-1693"></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1694"></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1695"></span><span class="hs-comment">-- Precondition: tys1 and tys2 are the same length, hence &quot;OK&quot;</span><span>
</span><span id="line-1696"></span><span id="canDecomposableTyConAppOK"><span class="annot"><span class="annottext">canDecomposableTyConAppOK :: CtEvidence
-&gt; EqRel
-&gt; TyCon
-&gt; [TcType]
-&gt; [TcType]
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canDecomposableTyConAppOK"><span class="hs-identifier hs-var hs-var">canDecomposableTyConAppOK</span></a></span></span><span> </span><span id="local-6989586621681116150"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116150"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116149"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116149"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116148"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116148"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681116147"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116147"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621681116146"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116146"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-1697"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tys1</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tys2</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1698"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canDecomposableTyConAppOK&quot;</span></span><span>
</span><span id="line-1699"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116150"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116149"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116148"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116147"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116146"><span class="hs-identifier hs-var">tys2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1700"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116150"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1701"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtDerived"><span class="hs-identifier hs-type">CtDerived</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>
</span><span id="line-1702"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [Role] -&gt; [TcType] -&gt; [TcType] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unifyDeriveds"><span class="hs-identifier hs-var">unifyDeriveds</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116145"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681116144"><span class="hs-identifier hs-var">tc_roles</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116147"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116146"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1703"></span><span>
</span><span id="line-1704"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116143"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116143"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1705"></span><span>                  </span><span class="hs-comment">-- new_locs and tc_roles are both infinite, so</span><span>
</span><span id="line-1706"></span><span>                  </span><span class="hs-comment">-- we are guaranteed that cos has the same length</span><span>
</span><span id="line-1707"></span><span>                  </span><span class="hs-comment">-- as tys1 and tys2</span><span>
</span><span id="line-1708"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116142"><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681116142"><span class="hs-identifier hs-var">cos</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion)
-&gt; [CtLoc] -&gt; [Role] -&gt; [TcType] -&gt; [TcType] -&gt; TcS [TcCoercion]
forall (m :: * -&gt; *) a b c d e.
Monad m =&gt;
(a -&gt; b -&gt; c -&gt; d -&gt; m e) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [d] -&gt; m [e]
</span><a href="GHC.Utils.Monad.html#zipWith4M"><span class="hs-identifier hs-var">zipWith4M</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">[CtLoc]
</span><a href="#local-6989586621681116140"><span class="hs-identifier hs-var">new_locs</span></a></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681116144"><span class="hs-identifier hs-var">tc_roles</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116147"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116146"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1709"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcEvDest -&gt; TcCoercion -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setWantedEq"><span class="hs-identifier hs-var">setWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681116143"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Role -&gt; TyCon -&gt; [TcCoercion] -&gt; TcCoercion
Role -&gt; TyCon -&gt; [TcCoercion] -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkTyConAppCo"><span class="hs-identifier hs-var">mkTyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116138"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116148"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681116142"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1710"></span><span>
</span><span id="line-1711"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtGiven"><span class="hs-identifier hs-type">CtGiven</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_evar :: CtEvidence -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctev_evar"><span class="hs-identifier hs-var">ctev_evar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116137"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116137"><span class="hs-identifier hs-var">evar</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1712"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116136"><span class="annot"><span class="annottext">ev_co :: TcCoercion
</span><a href="#local-6989586621681116136"><span class="hs-identifier hs-var hs-var">ev_co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116137"><span class="hs-identifier hs-var">evar</span></a></span><span>
</span><span id="line-1713"></span><span>                   </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116134"><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681116134"><span class="hs-identifier hs-var">given_evs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [(TcType, EvTerm)] -&gt; TcS [CtEvidence]
</span><a href="GHC.Tc.Solver.Monad.html#newGivenEvVars"><span class="hs-identifier hs-var">newGivenEvVars</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116145"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">([(TcType, EvTerm)] -&gt; TcS [CtEvidence])
-&gt; [(TcType, EvTerm)] -&gt; TcS [CtEvidence]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1714"></span><span>                                  </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.Coercion.html#mkPrimEqPredRole"><span class="hs-identifier hs-var">mkPrimEqPredRole</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116131"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116130"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116129"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1715"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">(TcCoercion -&gt; EvTerm) -&gt; TcCoercion -&gt; EvTerm
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Role -&gt; Int -&gt; TcCoercion -&gt; TcCoercion
Role -&gt; Int -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkNthCo"><span class="hs-identifier hs-var">mkNthCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116131"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681116127"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116136"><span class="hs-identifier hs-var">ev_co</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1716"></span><span>                                  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116131"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116131"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116130"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116130"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116129"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116129"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116127"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681116127"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Role]
-&gt; [TcType] -&gt; [TcType] -&gt; [Int] -&gt; [(Role, TcType, TcType, Int)]
forall a b c d. [a] -&gt; [b] -&gt; [c] -&gt; [d] -&gt; [(a, b, c, d)]
</span><a href="../../base/src/Data.OldList.html#zip4"><span class="hs-identifier hs-var">zip4</span></a></span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681116144"><span class="hs-identifier hs-var">tc_roles</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116147"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116146"><span class="hs-identifier hs-var">tys2</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span>
</span><span id="line-1717"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116131"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; Role -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Phantom"><span class="hs-identifier hs-var">Phantom</span></a></span><span>
</span><span id="line-1718"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isCoercionTy"><span class="hs-identifier hs-var">isCoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116130"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isCoercionTy"><span class="hs-identifier hs-var">isCoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116129"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1719"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[CtEvidence] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#emitWorkNC"><span class="hs-identifier hs-var">emitWorkNC</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681116134"><span class="hs-identifier hs-var">given_evs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1720"></span><span>
</span><span id="line-1721"></span><span>    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116150"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Decomposed TyConApp&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1722"></span><span>
</span><span id="line-1723"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1724"></span><span>    </span><span id="local-6989586621681116145"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681116145"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116150"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1725"></span><span>    </span><span id="local-6989586621681116138"><span class="annot"><span class="annottext">role :: Role
</span><a href="#local-6989586621681116138"><span class="hs-keyword hs-var hs-var">role</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116149"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-1726"></span><span>
</span><span id="line-1727"></span><span>      </span><span class="hs-comment">-- infinite, as tyConRolesX returns an infinite tail of Nominal</span><span>
</span><span id="line-1728"></span><span>    </span><span id="local-6989586621681116144"><span class="annot"><span class="annottext">tc_roles :: [Role]
</span><a href="#local-6989586621681116144"><span class="hs-identifier hs-var hs-var">tc_roles</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [Role]
</span><a href="GHC.Core.Coercion.html#tyConRolesX"><span class="hs-identifier hs-var">tyConRolesX</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116138"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116148"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-1729"></span><span>
</span><span id="line-1730"></span><span>      </span><span class="hs-comment">-- Add nuances to the location during decomposition:</span><span>
</span><span id="line-1731"></span><span>      </span><span class="hs-comment">--  * if the argument is a kind argument, remember this, so that error</span><span>
</span><span id="line-1732"></span><span>      </span><span class="hs-comment">--    messages say &quot;kind&quot;, not &quot;type&quot;. This is determined based on whether</span><span>
</span><span id="line-1733"></span><span>      </span><span class="hs-comment">--    the corresponding tyConBinder is named (that is, dependent)</span><span>
</span><span id="line-1734"></span><span>      </span><span class="hs-comment">--  * if the argument is invisible, note this as well, again by</span><span>
</span><span id="line-1735"></span><span>      </span><span class="hs-comment">--    looking at the corresponding binder</span><span>
</span><span id="line-1736"></span><span>      </span><span class="hs-comment">-- For oversaturated tycons, we need the (repeat loc) tail, which doesn't</span><span>
</span><span id="line-1737"></span><span>      </span><span class="hs-comment">-- do either of these changes. (Forgetting to do so led to #16188)</span><span>
</span><span id="line-1738"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-1739"></span><span>      </span><span class="hs-comment">-- NB: infinite in length</span><span>
</span><span id="line-1740"></span><span>    </span><span id="local-6989586621681116140"><span class="annot"><span class="annottext">new_locs :: [CtLoc]
</span><a href="#local-6989586621681116140"><span class="hs-identifier hs-var hs-var">new_locs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116123"><span class="hs-identifier hs-var">new_loc</span></a></span><span>
</span><span id="line-1741"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681116122"><span class="annot"><span class="annottext">TyConBinder
</span><a href="#local-6989586621681116122"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TyConBinder]
</span><a href="GHC.Core.TyCon.html#tyConBinders"><span class="hs-identifier hs-var hs-var">tyConBinders</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116148"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-1742"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116120"><span class="annot"><span class="annottext">new_loc0 :: CtLoc
</span><a href="#local-6989586621681116120"><span class="hs-identifier hs-var hs-var">new_loc0</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyConBinder -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isNamedTyConBinder"><span class="hs-identifier hs-var">isNamedTyConBinder</span></a></span><span> </span><span class="annot"><span class="annottext">TyConBinder
</span><a href="#local-6989586621681116122"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#toKindLoc"><span class="hs-identifier hs-var">toKindLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116145"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-1743"></span><span>                              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116145"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-1744"></span><span>                     </span><span id="local-6989586621681116123"><span class="annot"><span class="annottext">new_loc :: CtLoc
</span><a href="#local-6989586621681116123"><span class="hs-identifier hs-var hs-var">new_loc</span></a></span></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyConBinder -&gt; Bool
forall tv. VarBndr tv TyConBndrVis -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isVisibleTyConBinder"><span class="hs-identifier hs-var">isVisibleTyConBinder</span></a></span><span> </span><span class="annot"><span class="annottext">TyConBinder
</span><a href="#local-6989586621681116122"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1745"></span><span>                              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (CtOrigin -&gt; CtOrigin) -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#updateCtLocOrigin"><span class="hs-identifier hs-var">updateCtLocOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116120"><span class="hs-identifier hs-var">new_loc0</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#toInvisibleOrigin"><span class="hs-identifier hs-var">toInvisibleOrigin</span></a></span><span>
</span><span id="line-1746"></span><span>                              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1747"></span><span>                              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116120"><span class="hs-identifier hs-var">new_loc0</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1748"></span><span>               </span><span class="annot"><span class="annottext">[CtLoc] -&gt; [CtLoc] -&gt; [CtLoc]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [CtLoc]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116145"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-1749"></span><span>
</span><span id="line-1750"></span><span class="hs-comment">-- | Call when canonicalizing an equality fails, but if the equality is</span><span>
</span><span id="line-1751"></span><span class="hs-comment">-- representational, there is some hope for the future.</span><span>
</span><span id="line-1752"></span><span class="hs-comment">-- Examples in Note [Use canEqFailure in canDecomposableTyConApp]</span><span>
</span><span id="line-1753"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqFailure"><span class="hs-identifier hs-type">canEqFailure</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-1754"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1755"></span><span id="canEqFailure"><span class="annot"><span class="annottext">canEqFailure :: CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqFailure"><span class="hs-identifier hs-var hs-var">canEqFailure</span></a></span></span><span> </span><span id="local-6989586621681116115"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116115"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#NomEq"><span class="hs-identifier hs-var">NomEq</span></a></span><span> </span><span id="local-6989586621681116114"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116114"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116113"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116113"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1756"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqHardFailure"><span class="hs-identifier hs-var">canEqHardFailure</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116115"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116114"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116113"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1757"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqFailure"><span class="hs-identifier hs-var">canEqFailure</span></a></span><span> </span><span id="local-6989586621681116112"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116112"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#ReprEq"><span class="hs-identifier hs-var">ReprEq</span></a></span><span> </span><span id="local-6989586621681116111"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116111"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116110"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116110"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1758"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116109"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116109"><span class="hs-identifier hs-var">xi1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116108"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116108"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_FlattenAll"><span class="hs-identifier hs-var">FM_FlattenAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116112"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116111"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1759"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116107"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116107"><span class="hs-identifier hs-var">xi2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116106"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116106"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_FlattenAll"><span class="hs-identifier hs-var">FM_FlattenAll</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116112"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116110"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1760"></span><span>            </span><span class="hs-comment">-- We must flatten the types before putting them in the</span><span>
</span><span id="line-1761"></span><span>            </span><span class="hs-comment">-- inert set, so that we are sure to kick them out when</span><span>
</span><span id="line-1762"></span><span>            </span><span class="hs-comment">-- new equalities become available</span><span>
</span><span id="line-1763"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEqFailure with ReprEq&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1764"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116112"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116111"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116110"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116109"><span class="hs-identifier hs-var">xi1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116107"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1765"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116105"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116105"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116112"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116109"><span class="hs-identifier hs-var">xi1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116107"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116108"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116106"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-1766"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkIrredCt"><span class="hs-identifier hs-var">mkIrredCt</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#OtherCIS"><span class="hs-identifier hs-var">OtherCIS</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116105"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1767"></span><span>
</span><span id="line-1768"></span><span class="hs-comment">-- | Call when canonicalizing an equality fails with utterly no hope.</span><span>
</span><span id="line-1769"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqHardFailure"><span class="hs-identifier hs-type">canEqHardFailure</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-1770"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1771"></span><span class="hs-comment">-- See Note [Make sure that insolubles are fully rewritten]</span><span>
</span><span id="line-1772"></span><span id="canEqHardFailure"><span class="annot"><span class="annottext">canEqHardFailure :: CtEvidence -&gt; TcType -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqHardFailure"><span class="hs-identifier hs-var hs-var">canEqHardFailure</span></a></span></span><span> </span><span id="local-6989586621681116104"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116104"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116103"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116103"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681116102"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116102"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1773"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEqHardFailure&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116103"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116102"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1774"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116101"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116101"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116100"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116100"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_SubstOnly"><span class="hs-identifier hs-var">FM_SubstOnly</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116104"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116103"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1775"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116099"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116099"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116098"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116098"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FlattenMode -&gt; CtEvidence -&gt; TcType -&gt; TcS (TcType, TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flatten"><span class="hs-identifier hs-var">flatten</span></a></span><span> </span><span class="annot"><span class="annottext">FlattenMode
</span><a href="GHC.Tc.Solver.Flatten.html#FM_SubstOnly"><span class="hs-identifier hs-var">FM_SubstOnly</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116104"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116102"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1776"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116097"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116097"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116104"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116101"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116099"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116100"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116098"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-1777"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkIrredCt"><span class="hs-identifier hs-var">mkIrredCt</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#InsolubleCIS"><span class="hs-identifier hs-var">InsolubleCIS</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116097"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1778"></span><span>
</span><span id="line-1779"></span><span class="hs-comment">{-
Note [Decomposing TyConApps]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we see (T s1 t1 ~ T s2 t2), then we can just decompose to
  (s1 ~ s2, t1 ~ t2)
and push those back into the work list.  But if
  s1 = K k1    s2 = K k2
then we will just decomopose s1~s2, and it might be better to
do so on the spot.  An important special case is where s1=s2,
and we get just Refl.

So canDecomposableTyCon is a fast-path decomposition that uses
unifyWanted etc to short-cut that work.

Note [Canonicalising type applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Given (s1 t1) ~ ty2, how should we proceed?
The simple things is to see if ty2 is of form (s2 t2), and
decompose.  By this time s1 and s2 can't be saturated type
function applications, because those have been dealt with
by an earlier equation in can_eq_nc, so it is always sound to
decompose.

However, over-eager decomposition gives bad error messages
for things like
   a b ~ Maybe c
   e f ~ p -&gt; q
Suppose (in the first example) we already know a~Array.  Then if we
decompose the application eagerly, yielding
   a ~ Maybe
   b ~ c
we get an error        &quot;Can't match Array ~ Maybe&quot;,
but we'd prefer to get &quot;Can't match Array b ~ Maybe c&quot;.

So instead can_eq_wanted_app flattens the LHS and RHS, in the hope of
replacing (a b) by (Array b), before using try_decompose_app to
decompose it.

Note [Make sure that insolubles are fully rewritten]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When an equality fails, we still want to rewrite the equality
all the way down, so that it accurately reflects
 (a) the mutable reference substitution in force at start of solving
 (b) any ty-binds in force at this point in solving
See Note [Rewrite insolubles] in GHC.Tc.Solver.Monad.
And if we don't do this there is a bad danger that
GHC.Tc.Solver.applyTyVarDefaulting will find a variable
that has in fact been substituted.

Note [Do not decompose Given polytype equalities]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider [G] (forall a. t1 ~ forall a. t2).  Can we decompose this?
No -- what would the evidence look like?  So instead we simply discard
this given evidence.


Note [Combining insoluble constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As this point we have an insoluble constraint, like Int~Bool.

 * If it is Wanted, delete it from the cache, so that subsequent
   Int~Bool constraints give rise to separate error messages

 * But if it is Derived, DO NOT delete from cache.  A class constraint
   may get kicked out of the inert set, and then have its functional
   dependency Derived constraints generated a second time. In that
   case we don't want to get two (or more) error messages by
   generating two (or more) insoluble fundep constraints from the same
   class constraint.

Note [No top-level newtypes on RHS of representational equalities]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we're in this situation:

 work item:  [W] c1 : a ~R b
     inert:  [G] c2 : b ~R Id a

where
  newtype Id a = Id a

We want to make sure canEqTyVar sees [W] a ~R a, after b is flattened
and the Id newtype is unwrapped. This is assured by requiring only flat
types in canEqTyVar *and* having the newtype-unwrapping check above
the tyvar check in can_eq_nc.

Note [Occurs check error]
~~~~~~~~~~~~~~~~~~~~~~~~~
If we have an occurs check error, are we necessarily hosed? Say our
tyvar is tv1 and the type it appears in is xi2. Because xi2 is function
free, then if we're computing w.r.t. nominal equality, then, yes, we're
hosed. Nothing good can come from (a ~ [a]). If we're computing w.r.t.
representational equality, this is a little subtler. Once again, (a ~R [a])
is a bad thing, but (a ~R N a) for a newtype N might be just fine. This
means also that (a ~ b a) might be fine, because `b` might become a newtype.

So, we must check: does tv1 appear in xi2 under any type constructor
that is generative w.r.t. representational equality? That's what
isInsolubleOccursCheck does.

See also #10715, which induced this addition.

Note [canCFunEqCan]
~~~~~~~~~~~~~~~~~~~
Flattening the arguments to a type family can change the kind of the type
family application. As an easy example, consider (Any k) where (k ~ Type)
is in the inert set. The original (Any k :: k) becomes (Any Type :: Type).
The problem here is that the fsk in the CFunEqCan will have the old kind.

The solution is to come up with a new fsk/fmv of the right kind. For
givens, this is easy: just introduce a new fsk and update the flat-cache
with the new one. For wanteds, we want to solve the old one if favor of
the new one, so we use dischargeFmv. This also kicks out constraints
from the inert set; this behavior is correct, as the kind-change may
allow more constraints to be solved.

We use `isTcReflexiveCo`, to ensure that we only use the hetero-kinded case
if we really need to.  Of course `flattenArgsNom` should return `Refl`
whenever possible, but #15577 was an infinite loop because even
though the coercion was homo-kinded, `kind_co` was not `Refl`, so we
made a new (identical) CFunEqCan, and then the entire process repeated.
-}</span><span>
</span><span id="line-1900"></span><span>
</span><span id="line-1901"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canCFunEqCan"><span class="hs-identifier hs-type">canCFunEqCan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-1902"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- LHS</span><span>
</span><span id="line-1903"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>             </span><span class="hs-comment">-- RHS</span><span>
</span><span id="line-1904"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1905"></span><span class="hs-comment">-- ^ Canonicalise a CFunEqCan.  We know that</span><span>
</span><span id="line-1906"></span><span class="hs-comment">--     the arg types are already flat,</span><span>
</span><span id="line-1907"></span><span class="hs-comment">-- and the RHS is a fsk, which we must *not* substitute.</span><span>
</span><span id="line-1908"></span><span class="hs-comment">-- So just substitute in the LHS</span><span>
</span><span id="line-1909"></span><span id="canCFunEqCan"><span class="annot"><span class="annottext">canCFunEqCan :: CtEvidence
-&gt; TyCon -&gt; [TcType] -&gt; TcTyVar -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canCFunEqCan"><span class="hs-identifier hs-var hs-var">canCFunEqCan</span></a></span></span><span> </span><span id="local-6989586621681116096"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116096"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116095"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621681116094"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116094"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span id="local-6989586621681116093"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116093"><span class="hs-identifier hs-var">fsk</span></a></span></span><span>
</span><span id="line-1910"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116092"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116092"><span class="hs-identifier hs-var">tys'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116091"><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681116091"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116090"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116090"><span class="hs-identifier hs-var">kind_co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; TyCon -&gt; [TcType] -&gt; TcS ([TcType], [TcCoercion], TcCoercion)
</span><a href="GHC.Tc.Solver.Flatten.html#flattenArgsNom"><span class="hs-identifier hs-var">flattenArgsNom</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116096"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116094"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-1911"></span><span>                        </span><span class="hs-comment">-- cos :: tys' ~ tys</span><span>
</span><span id="line-1912"></span><span>
</span><span id="line-1913"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116089"><span class="annot"><span class="annottext">lhs_co :: TcCoercion
</span><a href="#local-6989586621681116089"><span class="hs-identifier hs-var hs-var">lhs_co</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [TcCoercion] -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcTyConAppCo"><span class="hs-identifier hs-var">mkTcTyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681116091"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-1914"></span><span>                        </span><span class="hs-comment">-- :: F tys' ~ F tys</span><span>
</span><span id="line-1915"></span><span>             </span><span id="local-6989586621681116088"><span class="annot"><span class="annottext">new_lhs :: TcType
</span><a href="#local-6989586621681116088"><span class="hs-identifier hs-var hs-var">new_lhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116092"><span class="hs-identifier hs-var">tys'</span></a></span><span>
</span><span id="line-1916"></span><span>
</span><span id="line-1917"></span><span>             </span><span id="local-6989586621681116087"><span class="annot"><span class="annottext">flav :: CtFlavour
</span><a href="#local-6989586621681116087"><span class="hs-identifier hs-var hs-var">flav</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtFlavour
</span><a href="GHC.Tc.Types.Constraint.html#ctEvFlavour"><span class="hs-identifier hs-var">ctEvFlavour</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116096"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-1918"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116086"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116086"><span class="hs-identifier hs-var">ev'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116085"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116085"><span class="hs-identifier hs-var">fsk'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1919"></span><span>           </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#isTcReflexiveCo"><span class="hs-identifier hs-var">isTcReflexiveCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116090"><span class="hs-identifier hs-var">kind_co</span></a></span><span>   </span><span class="hs-comment">-- See Note [canCFunEqCan]</span><span>
</span><span id="line-1920"></span><span>              </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canCFunEqCan: refl&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116088"><span class="hs-identifier hs-var">new_lhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1921"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116083"><span class="annot"><span class="annottext">fsk_ty :: TcType
</span><a href="#local-6989586621681116083"><span class="hs-identifier hs-var hs-var">fsk_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116093"><span class="hs-identifier hs-var">fsk</span></a></span><span>
</span><span id="line-1922"></span><span>                      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116082"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116082"><span class="hs-identifier hs-var">ev'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116096"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116088"><span class="hs-identifier hs-var">new_lhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116083"><span class="hs-identifier hs-var">fsk_ty</span></a></span><span>
</span><span id="line-1923"></span><span>                                                 </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116089"><span class="hs-identifier hs-var">lhs_co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcNomReflCo"><span class="hs-identifier hs-var">mkTcNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116083"><span class="hs-identifier hs-var">fsk_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1924"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CtEvidence, TcTyVar) -&gt; TcS (CtEvidence, TcTyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116082"><span class="hs-identifier hs-var">ev'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116093"><span class="hs-identifier hs-var">fsk</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1925"></span><span>              </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canCFunEqCan: non-refl&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1926"></span><span>                        </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Kind co:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116090"><span class="hs-identifier hs-var">kind_co</span></a></span><span>
</span><span id="line-1927"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;RHS:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116093"><span class="hs-identifier hs-var">fsk</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116093"><span class="hs-identifier hs-var">fsk</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1928"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;LHS:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116094"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1929"></span><span>                                                  </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116094"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1930"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;New LHS&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116088"><span class="hs-identifier hs-var">new_lhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1931"></span><span>                                                     </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116088"><span class="hs-identifier hs-var">new_lhs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1932"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116078"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116078"><span class="hs-identifier hs-var">ev'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116077"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116077"><span class="hs-identifier hs-var">new_co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116076"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116076"><span class="hs-identifier hs-var">new_fsk</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1933"></span><span>                          </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtFlavour
-&gt; CtLoc
-&gt; TyCon
-&gt; [TcType]
-&gt; TcS (CtEvidence, TcCoercion, TcTyVar)
</span><a href="GHC.Tc.Solver.Monad.html#newFlattenSkolem"><span class="hs-identifier hs-var">newFlattenSkolem</span></a></span><span> </span><span class="annot"><span class="annottext">CtFlavour
</span><a href="#local-6989586621681116087"><span class="hs-identifier hs-var">flav</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116096"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116092"><span class="hs-identifier hs-var">tys'</span></a></span><span>
</span><span id="line-1934"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116074"><span class="annot"><span class="annottext">xi :: TcType
</span><a href="#local-6989586621681116074"><span class="hs-identifier hs-var hs-var">xi</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116076"><span class="hs-identifier hs-var">new_fsk</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion -&gt; TcType
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116090"><span class="hs-identifier hs-var">kind_co</span></a></span><span>
</span><span id="line-1935"></span><span>                               </span><span class="hs-comment">-- sym lhs_co :: F tys ~ F tys'</span><span>
</span><span id="line-1936"></span><span>                               </span><span class="hs-comment">-- new_co     :: F tys' ~ new_fsk</span><span>
</span><span id="line-1937"></span><span>                               </span><span class="hs-comment">-- co         :: F tys ~ (new_fsk |&gt; kind_co)</span><span>
</span><span id="line-1938"></span><span>                            </span><span id="local-6989586621681116073"><span class="annot"><span class="annottext">co :: TcCoercion
</span><a href="#local-6989586621681116073"><span class="hs-identifier hs-var hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116089"><span class="hs-identifier hs-var">lhs_co</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcTransCo"><span class="hs-operator hs-var">`mkTcTransCo`</span></a></span><span>
</span><span id="line-1939"></span><span>                                 </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcCoherenceRightCo"><span class="hs-identifier hs-var">mkTcCoherenceRightCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span>
</span><span id="line-1940"></span><span>                                                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116076"><span class="hs-identifier hs-var">new_fsk</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1941"></span><span>                                                      </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116090"><span class="hs-identifier hs-var">kind_co</span></a></span><span>
</span><span id="line-1942"></span><span>                                                      </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116077"><span class="hs-identifier hs-var">new_co</span></a></span><span>
</span><span id="line-1943"></span><span>
</span><span id="line-1944"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Discharging fmv/fsk due to hetero flattening&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116096"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1945"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcTyVar -&gt; TcCoercion -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#dischargeFunEq"><span class="hs-identifier hs-var">dischargeFunEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116096"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116093"><span class="hs-identifier hs-var">fsk</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116073"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116074"><span class="hs-identifier hs-var">xi</span></a></span><span>
</span><span id="line-1946"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CtEvidence, TcTyVar) -&gt; TcS (CtEvidence, TcTyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116078"><span class="hs-identifier hs-var">ev'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116076"><span class="hs-identifier hs-var">new_fsk</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1947"></span><span>
</span><span id="line-1948"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TcType] -&gt; (TcCoercion, TcType, CtFlavour) -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#extendFlatCache"><span class="hs-identifier hs-var">extendFlatCache</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116092"><span class="hs-identifier hs-var">tys'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CtEvidence -&gt; TcCoercion
CtEvidence -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Constraint.html#ctEvCoercion"><span class="hs-identifier hs-var">ctEvCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116086"><span class="hs-identifier hs-var">ev'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116085"><span class="hs-identifier hs-var">fsk'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtFlavour
</span><a href="GHC.Tc.Types.Constraint.html#ctEvFlavour"><span class="hs-identifier hs-var">ctEvFlavour</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116086"><span class="hs-identifier hs-var">ev'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1949"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CFunEqCan :: CtEvidence -&gt; TyCon -&gt; [TcType] -&gt; TcTyVar -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#CFunEqCan"><span class="hs-identifier hs-type">CFunEqCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116086"><span class="hs-identifier hs-var">ev'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_fun :: TyCon
</span><a href="GHC.Tc.Types.Constraint.html#cc_fun"><span class="hs-identifier hs-var">cc_fun</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681116095"><span class="hs-identifier hs-var">fn</span></a></span><span>
</span><span id="line-1950"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: [TcType]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681116092"><span class="hs-identifier hs-var">tys'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_fsk :: TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#cc_fsk"><span class="hs-identifier hs-var">cc_fsk</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116085"><span class="hs-identifier hs-var">fsk'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1951"></span><span>
</span><span id="line-1952"></span><span class="hs-comment">---------------------</span><span>
</span><span id="line-1953"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar"><span class="hs-identifier hs-type">canEqTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>          </span><span class="hs-comment">-- ev :: lhs ~ rhs</span><span>
</span><span id="line-1954"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-1955"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>               </span><span class="hs-comment">-- tv1</span><span>
</span><span id="line-1956"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>                </span><span class="hs-comment">-- lhs: pretty lhs, already flat</span><span>
</span><span id="line-1957"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>      </span><span class="hs-comment">-- rhs: already flat</span><span>
</span><span id="line-1958"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1959"></span><span id="canEqTyVar"><span class="annot"><span class="annottext">canEqTyVar :: CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar"><span class="hs-identifier hs-var hs-var">canEqTyVar</span></a></span></span><span> </span><span id="local-6989586621681116067"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116067"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116066"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116066"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116065"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116065"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681116064"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116064"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681116063"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116063"><span class="hs-identifier hs-var">ps_xi1</span></a></span></span><span> </span><span id="local-6989586621681116062"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116062"><span class="hs-identifier hs-var">xi2</span></a></span></span><span> </span><span id="local-6989586621681116061"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116061"><span class="hs-identifier hs-var">ps_xi2</span></a></span></span><span>
</span><span id="line-1960"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116060"><span class="hs-identifier hs-var">k1</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-operator hs-var">`tcEqType`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116059"><span class="hs-identifier hs-var">k2</span></a></span><span>
</span><span id="line-1961"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHomo"><span class="hs-identifier hs-var">canEqTyVarHomo</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116067"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116066"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116065"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116064"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116063"><span class="hs-identifier hs-var">ps_xi1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116062"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116061"><span class="hs-identifier hs-var">ps_xi2</span></a></span><span>
</span><span id="line-1962"></span><span>
</span><span id="line-1963"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1964"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHetero"><span class="hs-identifier hs-var">canEqTyVarHetero</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116067"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116066"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116065"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116064"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116063"><span class="hs-identifier hs-var">ps_xi1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116060"><span class="hs-identifier hs-var">k1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116062"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116061"><span class="hs-identifier hs-var">ps_xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116059"><span class="hs-identifier hs-var">k2</span></a></span><span>
</span><span id="line-1965"></span><span>
</span><span id="line-1966"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1967"></span><span>    </span><span id="local-6989586621681116060"><span class="annot"><span class="annottext">k1 :: TcType
</span><a href="#local-6989586621681116060"><span class="hs-identifier hs-var hs-var">k1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116064"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1968"></span><span>    </span><span id="local-6989586621681116059"><span class="annot"><span class="annottext">k2 :: TcType
</span><a href="#local-6989586621681116059"><span class="hs-identifier hs-var hs-var">k2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116062"><span class="hs-identifier hs-var">xi2</span></a></span><span>
</span><span id="line-1969"></span><span>
</span><span id="line-1970"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHetero"><span class="hs-identifier hs-type">canEqTyVarHetero</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>         </span><span class="hs-comment">-- :: (tv1 :: ki1) ~ (xi2 :: ki2)</span><span>
</span><span id="line-1971"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-1972"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>  </span><span class="hs-comment">-- tv1, pretty tv1</span><span>
</span><span id="line-1973"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span>             </span><span class="hs-comment">-- ki1</span><span>
</span><span id="line-1974"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>   </span><span class="hs-comment">-- xi2, pretty xi2 :: ki2</span><span>
</span><span id="line-1975"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span>             </span><span class="hs-comment">-- ki2</span><span>
</span><span id="line-1976"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1977"></span><span id="canEqTyVarHetero"><span class="annot"><span class="annottext">canEqTyVarHetero :: CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHetero"><span class="hs-identifier hs-var hs-var">canEqTyVarHetero</span></a></span></span><span> </span><span id="local-6989586621681116054"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116054"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116053"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116053"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116052"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116052"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681116051"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116051"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681116050"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116050"><span class="hs-identifier hs-var">ps_tv1</span></a></span></span><span> </span><span id="local-6989586621681116049"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116049"><span class="hs-identifier hs-var">ki1</span></a></span></span><span> </span><span id="local-6989586621681116048"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116048"><span class="hs-identifier hs-var">xi2</span></a></span></span><span> </span><span id="local-6989586621681116047"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116047"><span class="hs-identifier hs-var">ps_xi2</span></a></span></span><span> </span><span id="local-6989586621681116046"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116046"><span class="hs-identifier hs-var">ki2</span></a></span></span><span>
</span><span id="line-1978"></span><span>  </span><span class="hs-comment">-- See Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-1979"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681116045"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116045"><span class="hs-identifier hs-var">kind_co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS TcCoercion
</span><a href="#local-6989586621681116044"><span class="hs-identifier hs-var">emit_kind_co</span></a></span><span>   </span><span class="hs-comment">-- :: ki2 ~N ki1</span><span>
</span><span id="line-1980"></span><span>
</span><span id="line-1981"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span>  </span><span class="hs-comment">-- kind_co :: (ki2 :: *) ~N (ki1 :: *)   (whether swapped or not)</span><span>
</span><span id="line-1982"></span><span>              </span><span class="hs-comment">-- co1     :: kind(tv1) ~N ki1</span><span>
</span><span id="line-1983"></span><span>             </span><span id="local-6989586621681116043"><span class="annot"><span class="annottext">rhs' :: TcType
</span><a href="#local-6989586621681116043"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116048"><span class="hs-identifier hs-var">xi2</span></a></span><span>    </span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion -&gt; TcType
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116045"><span class="hs-identifier hs-var">kind_co</span></a></span><span>   </span><span class="hs-comment">-- :: ki1</span><span>
</span><span id="line-1984"></span><span>             </span><span id="local-6989586621681116042"><span class="annot"><span class="annottext">ps_rhs' :: TcType
</span><a href="#local-6989586621681116042"><span class="hs-identifier hs-var hs-var">ps_rhs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116047"><span class="hs-identifier hs-var">ps_xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion -&gt; TcType
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116045"><span class="hs-identifier hs-var">kind_co</span></a></span><span>   </span><span class="hs-comment">-- :: ki1</span><span>
</span><span id="line-1985"></span><span>             </span><span id="local-6989586621681116041"><span class="annot"><span class="annottext">rhs_co :: TcCoercion
</span><a href="#local-6989586621681116041"><span class="hs-identifier hs-var hs-var">rhs_co</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcGReflLeftCo"><span class="hs-identifier hs-var">mkTcGReflLeftCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116039"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116048"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116045"><span class="hs-identifier hs-var">kind_co</span></a></span><span>
</span><span id="line-1986"></span><span>               </span><span class="hs-comment">-- rhs_co :: (xi2 |&gt; kind_co) ~ xi2</span><span>
</span><span id="line-1987"></span><span>
</span><span id="line-1988"></span><span>             </span><span id="local-6989586621681116038"><span class="annot"><span class="annottext">lhs' :: TcType
</span><a href="#local-6989586621681116038"><span class="hs-identifier hs-var hs-var">lhs'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116051"><span class="hs-identifier hs-var">tv1</span></a></span><span>  </span><span class="hs-comment">-- same as old lhs</span><span>
</span><span id="line-1989"></span><span>             </span><span id="local-6989586621681116037"><span class="annot"><span class="annottext">lhs_co :: TcCoercion
</span><a href="#local-6989586621681116037"><span class="hs-identifier hs-var hs-var">lhs_co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116039"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116038"><span class="hs-identifier hs-var">lhs'</span></a></span><span>
</span><span id="line-1990"></span><span>
</span><span id="line-1991"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Hetero equality gives rise to kind equality&quot;</span></span><span>
</span><span id="line-1992"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116045"><span class="hs-identifier hs-var">kind_co</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116046"><span class="hs-identifier hs-var">ki2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~#&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116049"><span class="hs-identifier hs-var">ki1</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1993"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116035"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116035"><span class="hs-identifier hs-var">type_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116054"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116052"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116038"><span class="hs-identifier hs-var">lhs'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116043"><span class="hs-identifier hs-var">rhs'</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116037"><span class="hs-identifier hs-var">lhs_co</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116041"><span class="hs-identifier hs-var">rhs_co</span></a></span><span>
</span><span id="line-1994"></span><span>
</span><span id="line-1995"></span><span>          </span><span class="hs-comment">-- rewriteEqEvidence carries out the swap, so we're NotSwapped any more</span><span>
</span><span id="line-1996"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHomo"><span class="hs-identifier hs-var">canEqTyVarHomo</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116035"><span class="hs-identifier hs-var">type_ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116053"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116051"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116050"><span class="hs-identifier hs-var">ps_tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116043"><span class="hs-identifier hs-var">rhs'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116042"><span class="hs-identifier hs-var">ps_rhs'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1997"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1998"></span><span>    </span><span class="annot"><a href="#local-6989586621681116044"><span class="hs-identifier hs-type">emit_kind_co</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionN"><span class="hs-identifier hs-type">CoercionN</span></a></span><span>
</span><span id="line-1999"></span><span>    </span><span id="local-6989586621681116044"><span class="annot"><span class="annottext">emit_kind_co :: TcS TcCoercion
</span><a href="#local-6989586621681116044"><span class="hs-identifier hs-var hs-var">emit_kind_co</span></a></span></span><span>
</span><span id="line-2000"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtGiven"><span class="hs-identifier hs-type">CtGiven</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_evar :: CtEvidence -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctev_evar"><span class="hs-identifier hs-var">ctev_evar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681116033"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116033"><span class="hs-identifier hs-var">evar</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116054"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-2001"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116032"><span class="annot"><span class="annottext">kind_co :: TcCoercion
</span><a href="#local-6989586621681116032"><span class="hs-identifier hs-var hs-var">kind_co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="#local-6989586621681116031"><span class="hs-identifier hs-var">maybe_sym</span></a></span><span> </span><span class="annot"><span class="annottext">(TcCoercion -&gt; TcCoercion) -&gt; TcCoercion -&gt; TcCoercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcKindCo"><span class="hs-identifier hs-var">mkTcKindCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcCoVarCo"><span class="hs-identifier hs-var">mkTcCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116033"><span class="hs-identifier hs-var">evar</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- :: k2 ~ k1</span><span>
</span><span id="line-2002"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116029"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116029"><span class="hs-identifier hs-var">kind_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (TcType, EvTerm) -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newGivenEvVar"><span class="hs-identifier hs-var">newGivenEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116028"><span class="hs-identifier hs-var">kind_loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116027"><span class="hs-identifier hs-var">kind_pty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116032"><span class="hs-identifier hs-var">kind_co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2003"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[CtEvidence] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#emitWorkNC"><span class="hs-identifier hs-var">emitWorkNC</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116029"><span class="hs-identifier hs-var">kind_ev</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2004"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcS TcCoercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CtEvidence -&gt; TcCoercion
CtEvidence -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Constraint.html#ctEvCoercion"><span class="hs-identifier hs-var">ctEvCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116029"><span class="hs-identifier hs-var">kind_ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2005"></span><span>
</span><span id="line-2006"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2007"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116028"><span class="hs-identifier hs-var">kind_loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116046"><span class="hs-identifier hs-var">ki2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116049"><span class="hs-identifier hs-var">ki1</span></a></span><span>
</span><span id="line-2008"></span><span>
</span><span id="line-2009"></span><span>    </span><span id="local-6989586621681116026"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681116026"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var hs-var">ctev_loc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116054"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-2010"></span><span>    </span><span id="local-6989586621681116039"><span class="annot"><span class="annottext">role :: Role
</span><a href="#local-6989586621681116039"><span class="hs-keyword hs-var hs-var">role</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116053"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-2011"></span><span>    </span><span id="local-6989586621681116028"><span class="annot"><span class="annottext">kind_loc :: CtLoc
</span><a href="#local-6989586621681116028"><span class="hs-identifier hs-var hs-var">kind_loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; CtLoc -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#mkKindLoc"><span class="hs-identifier hs-var">mkKindLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116051"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116048"><span class="hs-identifier hs-var">xi2</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681116026"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-2012"></span><span>    </span><span id="local-6989586621681116027"><span class="annot"><span class="annottext">kind_pty :: TcType
</span><a href="#local-6989586621681116027"><span class="hs-identifier hs-var hs-var">kind_pty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.Coercion.html#mkHeteroPrimEqPred"><span class="hs-identifier hs-var">mkHeteroPrimEqPred</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116046"><span class="hs-identifier hs-var">ki2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116049"><span class="hs-identifier hs-var">ki1</span></a></span><span>
</span><span id="line-2013"></span><span>
</span><span id="line-2014"></span><span>    </span><span id="local-6989586621681116031"><span class="annot"><span class="annottext">maybe_sym :: TcCoercion -&gt; TcCoercion
</span><a href="#local-6989586621681116031"><span class="hs-identifier hs-var hs-var">maybe_sym</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116052"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2015"></span><span>          </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>         </span><span class="hs-comment">-- if the input is swapped, then we already</span><span>
</span><span id="line-2016"></span><span>                                   </span><span class="hs-comment">-- will have k2 ~ k1</span><span>
</span><span id="line-2017"></span><span>          </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span>
</span><span id="line-2018"></span><span>
</span><span id="line-2019"></span><span class="hs-comment">-- guaranteed that tcTypeKind lhs == tcTypeKind rhs</span><span>
</span><span id="line-2020"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHomo"><span class="hs-identifier hs-type">canEqTyVarHomo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-2021"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-2022"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>                </span><span class="hs-comment">-- lhs: tv1</span><span>
</span><span id="line-2023"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>                 </span><span class="hs-comment">-- pretty lhs, flat</span><span>
</span><span id="line-2024"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>       </span><span class="hs-comment">-- rhs, flat</span><span>
</span><span id="line-2025"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2026"></span><span id="canEqTyVarHomo"><span class="annot"><span class="annottext">canEqTyVarHomo :: CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcType
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHomo"><span class="hs-identifier hs-var hs-var">canEqTyVarHomo</span></a></span></span><span> </span><span id="local-6989586621681116021"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116021"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681116020"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116020"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681116019"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116019"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681116018"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116018"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681116017"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116017"><span class="hs-identifier hs-var">ps_xi1</span></a></span></span><span> </span><span id="local-6989586621681116016"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116016"><span class="hs-identifier hs-var">xi2</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-2027"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116015"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116015"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcTyVar, TcCoercion)
</span><a href="GHC.Tc.Utils.TcType.html#tcGetCastedTyVar_maybe"><span class="hs-identifier hs-var">tcGetCastedTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116016"><span class="hs-identifier hs-var">xi2</span></a></span><span>
</span><span id="line-2028"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116018"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116015"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-2029"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqReflexive"><span class="hs-identifier hs-var">canEqReflexive</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116021"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116020"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116018"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2030"></span><span>    </span><span class="hs-comment">-- we don't need to check co because it must be reflexive</span><span>
</span><span id="line-2031"></span><span>
</span><span id="line-2032"></span><span>    </span><span class="hs-comment">-- this guarantees (TyEq:TV)</span><span>
</span><span id="line-2033"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681116013"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116013"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681116012"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116012"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcTyVar, TcCoercion)
</span><a href="GHC.Tc.Utils.TcType.html#tcGetCastedTyVar_maybe"><span class="hs-identifier hs-var">tcGetCastedTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116016"><span class="hs-identifier hs-var">xi2</span></a></span><span>
</span><span id="line-2034"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcTyVar -&gt; TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#swapOverTyVars"><span class="hs-identifier hs-var">swapOverTyVars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isGiven"><span class="hs-identifier hs-var">isGiven</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116021"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116018"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116013"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-2035"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEqTyVar swapOver&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116018"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116013"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116019"><span class="hs-identifier hs-var">swapped</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2036"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681116011"><span class="annot"><span class="annottext">role :: Role
</span><a href="#local-6989586621681116011"><span class="hs-keyword hs-var hs-var">role</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116020"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-2037"></span><span>             </span><span id="local-6989586621681116010"><span class="annot"><span class="annottext">sym_co2 :: TcCoercion
</span><a href="#local-6989586621681116010"><span class="hs-identifier hs-var hs-var">sym_co2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116012"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-2038"></span><span>             </span><span id="local-6989586621681116009"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681116009"><span class="hs-identifier hs-var hs-var">ty1</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116018"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-2039"></span><span>             </span><span id="local-6989586621681116008"><span class="annot"><span class="annottext">new_lhs :: TcType
</span><a href="#local-6989586621681116008"><span class="hs-identifier hs-var hs-var">new_lhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116009"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion -&gt; TcType
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116010"><span class="hs-identifier hs-var">sym_co2</span></a></span><span>
</span><span id="line-2040"></span><span>             </span><span id="local-6989586621681116007"><span class="annot"><span class="annottext">lhs_co :: TcCoercion
</span><a href="#local-6989586621681116007"><span class="hs-identifier hs-var hs-var">lhs_co</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcGReflLeftCo"><span class="hs-identifier hs-var">mkTcGReflLeftCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116011"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116009"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116010"><span class="hs-identifier hs-var">sym_co2</span></a></span><span>
</span><span id="line-2041"></span><span>
</span><span id="line-2042"></span><span>             </span><span id="local-6989586621681116006"><span class="annot"><span class="annottext">new_rhs :: TcType
</span><a href="#local-6989586621681116006"><span class="hs-identifier hs-var hs-var">new_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116013"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-2043"></span><span>             </span><span id="local-6989586621681116005"><span class="annot"><span class="annottext">rhs_co :: TcCoercion
</span><a href="#local-6989586621681116005"><span class="hs-identifier hs-var hs-var">rhs_co</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcGReflRightCo"><span class="hs-identifier hs-var">mkTcGReflRightCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681116011"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116006"><span class="hs-identifier hs-var">new_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116012"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-2044"></span><span>
</span><span id="line-2045"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116004"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116004"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116021"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681116019"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116008"><span class="hs-identifier hs-var">new_lhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116006"><span class="hs-identifier hs-var">new_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116007"><span class="hs-identifier hs-var">lhs_co</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116005"><span class="hs-identifier hs-var">rhs_co</span></a></span><span>
</span><span id="line-2046"></span><span>
</span><span id="line-2047"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681116003"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681116003"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-2048"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar2"><span class="hs-identifier hs-var">canEqTyVar2</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681116003"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116004"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681116020"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681116013"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681116017"><span class="hs-identifier hs-var">ps_xi1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcCoercion -&gt; TcType
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681116010"><span class="hs-identifier hs-var">sym_co2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2049"></span><span>
</span><span id="line-2050"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqTyVarHomo"><span class="hs-identifier hs-var">canEqTyVarHomo</span></a></span><span> </span><span id="local-6989586621681116000"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116000"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681115999"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115999"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681115998"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115998"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681115997"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115997"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681115996"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115996"><span class="hs-identifier hs-var">ps_xi2</span></a></span></span><span>
</span><span id="line-2051"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115995"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681115995"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-2052"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar2"><span class="hs-identifier hs-var">canEqTyVar2</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681115995"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681116000"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115999"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115998"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115997"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115996"><span class="hs-identifier hs-var">ps_xi2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2053"></span><span>
</span><span id="line-2054"></span><span class="hs-comment">-- The RHS here is either not a casted tyvar, or it's a tyvar but we want</span><span>
</span><span id="line-2055"></span><span class="hs-comment">-- to rewrite the LHS to the RHS (as per swapOverTyVars)</span><span>
</span><span id="line-2056"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar2"><span class="hs-identifier hs-type">canEqTyVar2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-2057"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>   </span><span class="hs-comment">-- lhs ~ rhs (or, if swapped, orhs ~ olhs)</span><span>
</span><span id="line-2058"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-2059"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-2060"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>                  </span><span class="hs-comment">-- lhs = tv, flat</span><span>
</span><span id="line-2061"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>                   </span><span class="hs-comment">-- rhs, flat</span><span>
</span><span id="line-2062"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2063"></span><span class="hs-comment">-- LHS is an inert type variable,</span><span>
</span><span id="line-2064"></span><span class="hs-comment">-- and RHS is fully rewritten, but with type synonyms</span><span>
</span><span id="line-2065"></span><span class="hs-comment">-- preserved as much as possible</span><span>
</span><span id="line-2066"></span><span class="hs-comment">-- guaranteed that tyVarKind lhs == typeKind rhs, for (TyEq:K)</span><span>
</span><span id="line-2067"></span><span class="hs-comment">-- the &quot;flat&quot; requirement guarantees (TyEq:AFF)</span><span>
</span><span id="line-2068"></span><span class="hs-comment">-- (TyEq:N) is checked in can_eq_nc', and (TyEq:TV) is handled in canEqTyVarHomo</span><span>
</span><span id="line-2069"></span><span id="canEqTyVar2"><span class="annot"><span class="annottext">canEqTyVar2 :: DynFlags
-&gt; CtEvidence
-&gt; EqRel
-&gt; SwapFlag
-&gt; TcTyVar
-&gt; TcType
-&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqTyVar2"><span class="hs-identifier hs-var hs-var">canEqTyVar2</span></a></span></span><span> </span><span id="local-6989586621681115994"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681115994"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681115993"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115993"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681115992"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115992"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681115991"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115991"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681115990"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115990"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681115989"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115989"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-2070"></span><span>    </span><span class="hs-comment">-- this next line checks also for coercion holes; see</span><span>
</span><span id="line-2071"></span><span>    </span><span class="hs-comment">-- Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-2072"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-type">MTVU_OK</span></a></span><span> </span><span id="local-6989586621681115987"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115987"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult TcType
</span><a href="#local-6989586621681115986"><span class="hs-identifier hs-var">mtvu</span></a></span><span>  </span><span class="hs-comment">-- No occurs check</span><span>
</span><span id="line-2073"></span><span>     </span><span class="hs-comment">-- Must do the occurs check even on tyvar/tyvar</span><span>
</span><span id="line-2074"></span><span>     </span><span class="hs-comment">-- equalities, in case have  x ~ (y :: ..x...)</span><span>
</span><span id="line-2075"></span><span>     </span><span class="hs-comment">-- #12593</span><span>
</span><span id="line-2076"></span><span>     </span><span class="hs-comment">-- guarantees (TyEq:OC), (TyEq:F), and (TyEq:H)</span><span>
</span><span id="line-2077"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115985"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115985"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115993"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115991"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115984"><span class="hs-identifier hs-var">lhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115987"><span class="hs-identifier hs-var">rhs'</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115983"><span class="hs-identifier hs-var">rewrite_co1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115982"><span class="hs-identifier hs-var">rewrite_co2</span></a></span><span>
</span><span id="line-2078"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CTyEqCan :: CtEvidence -&gt; TcTyVar -&gt; TcType -&gt; EqRel -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#CTyEqCan"><span class="hs-identifier hs-type">CTyEqCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115985"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyvar :: TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyvar"><span class="hs-identifier hs-var">cc_tyvar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115990"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-2079"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_rhs :: TcType
</span><a href="GHC.Tc.Types.Constraint.html#cc_rhs"><span class="hs-identifier hs-var">cc_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115987"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_eq_rel :: EqRel
</span><a href="GHC.Tc.Types.Constraint.html#cc_eq_rel"><span class="hs-identifier hs-var">cc_eq_rel</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115992"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2080"></span><span>
</span><span id="line-2081"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- For some reason (occurs check, or forall) we can't unify</span><span>
</span><span id="line-2082"></span><span>               </span><span class="hs-comment">-- We must not use it for further rewriting!</span><span>
</span><span id="line-2083"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;canEqTyVar2 can't unify&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115990"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115989"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2084"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681115981"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115981"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var">rewriteEqEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115993"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115991"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115984"><span class="hs-identifier hs-var">lhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115989"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115983"><span class="hs-identifier hs-var">rewrite_co1</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115982"><span class="hs-identifier hs-var">rewrite_co2</span></a></span><span>
</span><span id="line-2085"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681115980"><span class="annot"><span class="annottext">status :: CtIrredStatus
</span><a href="#local-6989586621681115980"><span class="hs-identifier hs-var hs-var">status</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; TcTyVar -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isInsolubleOccursCheck"><span class="hs-identifier hs-var">isInsolubleOccursCheck</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115992"><span class="hs-identifier hs-var">eq_rel</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115990"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115989"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-2086"></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#InsolubleCIS"><span class="hs-identifier hs-var">InsolubleCIS</span></a></span><span>
</span><span id="line-2087"></span><span>             </span><span class="hs-comment">-- If we have a ~ [a], it is not canonical, and in particular</span><span>
</span><span id="line-2088"></span><span>             </span><span class="hs-comment">-- we don't want to rewrite existing inerts with it, otherwise</span><span>
</span><span id="line-2089"></span><span>             </span><span class="hs-comment">-- we'd risk divergence in the constraint solver</span><span>
</span><span id="line-2090"></span><span>
</span><span id="line-2091"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult TcType
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult TcType
</span><a href="#local-6989586621681115986"><span class="hs-identifier hs-var">mtvu</span></a></span><span>
</span><span id="line-2092"></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#BlockedCIS"><span class="hs-identifier hs-var">BlockedCIS</span></a></span><span>
</span><span id="line-2093"></span><span>             </span><span class="hs-comment">-- This is the case detailed in</span><span>
</span><span id="line-2094"></span><span>             </span><span class="hs-comment">-- Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-2095"></span><span>
</span><span id="line-2096"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2097"></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="GHC.Tc.Types.Constraint.html#OtherCIS"><span class="hs-identifier hs-var">OtherCIS</span></a></span><span>
</span><span id="line-2098"></span><span>             </span><span class="hs-comment">-- A representational equality with an occurs-check problem isn't</span><span>
</span><span id="line-2099"></span><span>             </span><span class="hs-comment">-- insoluble! For example:</span><span>
</span><span id="line-2100"></span><span>             </span><span class="hs-comment">--   a ~R b a</span><span>
</span><span id="line-2101"></span><span>             </span><span class="hs-comment">-- We might learn that b is the newtype Id.</span><span>
</span><span id="line-2102"></span><span>             </span><span class="hs-comment">-- But, the occurs-check certainly prevents the equality from being</span><span>
</span><span id="line-2103"></span><span>             </span><span class="hs-comment">-- canonical, and we might loop if we were to use it in rewriting.</span><span>
</span><span id="line-2104"></span><span>
</span><span id="line-2105"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (StopOrContinue Ct)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtIrredStatus -&gt; CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkIrredCt"><span class="hs-identifier hs-var">mkIrredCt</span></a></span><span> </span><span class="annot"><span class="annottext">CtIrredStatus
</span><a href="#local-6989586621681115980"><span class="hs-identifier hs-var">status</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115981"><span class="hs-identifier hs-var">new_ev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2106"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2107"></span><span>    </span><span id="local-6989586621681115986"><span class="annot"><span class="annottext">mtvu :: MetaTyVarUpdateResult TcType
</span><a href="#local-6989586621681115986"><span class="hs-identifier hs-var hs-var">mtvu</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; TcTyVar -&gt; TcType -&gt; MetaTyVarUpdateResult TcType
</span><a href="GHC.Tc.Utils.Unify.html#metaTyVarUpdateOK"><span class="hs-identifier hs-var">metaTyVarUpdateOK</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681115994"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115990"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115989"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-2108"></span><span>
</span><span id="line-2109"></span><span>    </span><span id="local-6989586621681115976"><span class="annot"><span class="annottext">role :: Role
</span><a href="#local-6989586621681115976"><span class="hs-keyword hs-var hs-var">role</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115992"><span class="hs-identifier hs-var">eq_rel</span></a></span><span>
</span><span id="line-2110"></span><span>
</span><span id="line-2111"></span><span>    </span><span id="local-6989586621681115984"><span class="annot"><span class="annottext">lhs :: TcType
</span><a href="#local-6989586621681115984"><span class="hs-identifier hs-var hs-var">lhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115990"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-2112"></span><span>
</span><span id="line-2113"></span><span>    </span><span id="local-6989586621681115983"><span class="annot"><span class="annottext">rewrite_co1 :: TcCoercion
</span><a href="#local-6989586621681115983"><span class="hs-identifier hs-var hs-var">rewrite_co1</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115976"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115984"><span class="hs-identifier hs-var">lhs</span></a></span><span>
</span><span id="line-2114"></span><span>    </span><span id="local-6989586621681115982"><span class="annot"><span class="annottext">rewrite_co2 :: TcCoercion
</span><a href="#local-6989586621681115982"><span class="hs-identifier hs-var hs-var">rewrite_co2</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115976"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115989"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-2115"></span><span>
</span><span id="line-2116"></span><span class="hs-comment">-- | Solve a reflexive equality constraint</span><span>
</span><span id="line-2117"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#canEqReflexive"><span class="hs-identifier hs-type">canEqReflexive</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>    </span><span class="hs-comment">-- ty ~ ty</span><span>
</span><span id="line-2118"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqRel"><span class="hs-identifier hs-type">EqRel</span></a></span><span>
</span><span id="line-2119"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>        </span><span class="hs-comment">-- ty</span><span>
</span><span id="line-2120"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- always Stop</span><span>
</span><span id="line-2121"></span><span id="canEqReflexive"><span class="annot"><span class="annottext">canEqReflexive :: CtEvidence -&gt; EqRel -&gt; TcType -&gt; TcS (StopOrContinue Ct)
</span><a href="GHC.Tc.Solver.Canonical.html#canEqReflexive"><span class="hs-identifier hs-var hs-var">canEqReflexive</span></a></span></span><span> </span><span id="local-6989586621681115975"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115975"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681115974"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115974"><span class="hs-identifier hs-var">eq_rel</span></a></span></span><span> </span><span id="local-6989586621681115973"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115973"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-2122"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EvTerm -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setEvBindIfWanted"><span class="hs-identifier hs-var">setEvBindIfWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115975"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">(TcCoercion -&gt; EvTerm) -&gt; TcCoercion -&gt; EvTerm
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2123"></span><span>                               </span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681115974"><span class="hs-identifier hs-var">eq_rel</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115973"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2124"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue Ct)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115975"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Solved by reflexivity&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2125"></span><span>
</span><span id="line-2126"></span><span class="hs-comment">{- Note [Equalities with incompatible kinds]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What do we do when we have an equality

  (tv :: k1) ~ (rhs :: k2)

where k1 and k2 differ? Easy: we create a coercion that relates k1 and
k2 and use this to cast. To wit, from

  [X] (tv :: k1) ~ (rhs :: k2)

we go to

  [noDerived X] co :: k2 ~ k1
  [X]           (tv :: k1) ~ ((rhs |&gt; co) :: k1)

where

  noDerived G = G
  noDerived _ = W

Wrinkles:

 (1) The noDerived step is because Derived equalities have no evidence.
     And yet we absolutely need evidence to be able to proceed here.
     Given evidence will use the KindCo coercion; Wanted evidence will
     be a coercion hole. Even a Derived hetero equality begets a Wanted
     kind equality.

 (2) Though it would be sound to do so, we must not mark the rewritten Wanted
       [W] (tv :: k1) ~ ((rhs |&gt; co) :: k1)
     as canonical in the inert set. In particular, we must not unify tv.
     If we did, the Wanted becomes a Given (effectively), and then can
     rewrite other Wanteds. But that's bad: See Note [Wanteds to not rewrite Wanteds]
     in GHC.Tc.Types.Constraint. The problem is about poor error messages. See #11198 for
     tales of destruction.

     So, we have an invariant on CTyEqCan (TyEq:H) that the RHS does not have
     any coercion holes. This is checked in metaTyVarUpdateOK. We also
     must be sure to kick out any constraints that mention coercion holes
     when those holes get filled in.

     (2a) We don't want to do this for CoercionHoles that witness
          CFunEqCans (that are produced by the flattener), as these will disappear
          once we unflatten. So we remember in the CoercionHole structure
          whether the presence of the hole should block substitution or not.
          A bit gross, this.

     (2b) We must now absolutely make sure to kick out any constraints that
          mention a newly-filled-in coercion hole. This is done in
          kickOutAfterFillingCoercionHole.

 (3) Suppose we have [W] (a :: k1) ~ (rhs :: k2). We duly follow the
     algorithm detailed here, producing [W] co :: k2 ~ k1, and adding
     [W] (a :: k1) ~ ((rhs |&gt; co) :: k1) to the irreducibles. Some time
     later, we solve co, and fill in co's coercion hole. This kicks out
     the irreducible as described in (2b).
     But now, during canonicalization, we see the cast
     and remove it, in canEqCast. By the time we get into canEqTyVar, the equality
     is heterogeneous again, and the process repeats.

     To avoid this, we don't strip casts off a type if the other type
     in the equality is a tyvar. And this is an improvement regardless:
     because tyvars can, generally, unify with casted types, there's no
     reason to go through the work of stripping off the cast when the
     cast appears opposite a tyvar. This is implemented in the cast case
     of can_eq_nc'.

 (4) Reporting an error for a constraint that is blocked only because
     of wrinkle (2) is hard: what would we say to users? And we don't
     really need to report, because if a constraint is blocked, then
     there is unsolved wanted blocking it; that unsolved wanted will
     be reported. We thus push such errors to the bottom of the queue
     in the error-reporting code; they should never be printed.

     (4a) It would seem possible to do this filtering just based on the
          presence of a blocking coercion hole. However, this is no good,
          as it suppresses e.g. no-instance-found errors. We thus record
          a CtIrredStatus in CIrredCan and filter based on this status.
          This happened in T14584. An alternative approach is to expressly
          look for *equalities* with blocking coercion holes, but actually
          recording the blockage in a status field seems nicer.

     (4b) The error message might be printed with -fdefer-type-errors,
          so it still must exist. This is the only reason why there is
          a message at all. Otherwise, we could simply do nothing.

Historical note:

We used to do this via emitting a Derived kind equality and then parking
the heterogeneous equality as irreducible. But this new approach is much
more direct. And it doesn't produce duplicate Deriveds (as the old one did).

Note [Type synonyms and canonicalization]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We treat type synonym applications as xi types, that is, they do not
count as type function applications.  However, we do need to be a bit
careful with type synonyms: like type functions they may not be
generative or injective.  However, unlike type functions, they are
parametric, so there is no problem in expanding them whenever we see
them, since we do not need to know anything about their arguments in
order to expand them; this is what justifies not having to treat them
as specially as type function applications.  The thing that causes
some subtleties is that we prefer to leave type synonym applications
*unexpanded* whenever possible, in order to generate better error
messages.

If we encounter an equality constraint with type synonym applications
on both sides, or a type synonym application on one side and some sort
of type application on the other, we simply must expand out the type
synonyms in order to continue decomposing the equality constraint into
primitive equality constraints.  For example, suppose we have

  type F a = [Int]

and we encounter the equality

  F a ~ [b]

In order to continue we must expand F a into [Int], giving us the
equality

  [Int] ~ [b]

which we can then decompose into the more primitive equality
constraint

  Int ~ b.

However, if we encounter an equality constraint with a type synonym
application on one side and a variable on the other side, we should
NOT (necessarily) expand the type synonym, since for the purpose of
good error messages we want to leave type synonyms unexpanded as much
as possible.  Hence the ps_xi1, ps_xi2 argument passed to canEqTyVar.

-}</span><span>
</span><span id="line-2262"></span><span>
</span><span id="line-2263"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                  Evidence transformation
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-2270"></span><span>
</span><span id="line-2271"></span><span class="hs-keyword">data</span><span> </span><span id="StopOrContinue"><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-var">StopOrContinue</span></a></span></span><span> </span><span id="local-6989586621681117360"><span class="annot"><a href="#local-6989586621681117360"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-2272"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="ContinueWith"><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#ContinueWith"><span class="hs-identifier hs-var">ContinueWith</span></a></span></span><span> </span><span class="annot"><a href="#local-6989586621681117360"><span class="hs-identifier hs-type">a</span></a></span><span>    </span><span class="hs-comment">-- The constraint was not solved, although it may have</span><span>
</span><span id="line-2273"></span><span>                      </span><span class="hs-comment">--   been rewritten</span><span>
</span><span id="line-2274"></span><span>
</span><span id="line-2275"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="Stop"><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#Stop"><span class="hs-identifier hs-var">Stop</span></a></span></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>   </span><span class="hs-comment">-- The (rewritten) constraint was solved</span><span>
</span><span id="line-2276"></span><span>         </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>         </span><span class="hs-comment">-- Tells how it was solved</span><span>
</span><span id="line-2277"></span><span>                      </span><span class="hs-comment">-- Any new sub-goals have been put on the work list</span><span>
</span><span id="line-2278"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681115967"><span id="local-6989586621681115969"><span class="annot"><span class="annottext">(forall a b. (a -&gt; b) -&gt; StopOrContinue a -&gt; StopOrContinue b)
-&gt; (forall a b. a -&gt; StopOrContinue b -&gt; StopOrContinue a)
-&gt; Functor StopOrContinue
forall a b. a -&gt; StopOrContinue b -&gt; StopOrContinue a
forall a b. (a -&gt; b) -&gt; StopOrContinue a -&gt; StopOrContinue b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; StopOrContinue b -&gt; StopOrContinue a
$c&lt;$ :: forall a b. a -&gt; StopOrContinue b -&gt; StopOrContinue a
fmap :: forall a b. (a -&gt; b) -&gt; StopOrContinue a -&gt; StopOrContinue b
$cfmap :: forall a b. (a -&gt; b) -&gt; StopOrContinue a -&gt; StopOrContinue b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-2279"></span><span>
</span><span id="line-2280"></span><span id="local-6989586621681117513"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681115963"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117513"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117513"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2281"></span><span>  </span><span id="local-6989586621681115959"><span class="annot"><span class="annottext">ppr :: StopOrContinue a -&gt; SDoc
</span><a href="#local-6989586621681115959"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#Stop"><span class="hs-identifier hs-type">Stop</span></a></span><span> </span><span id="local-6989586621681115958"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115958"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681115957"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681115957"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Stop&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681115957"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115958"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-2282"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#ContinueWith"><span class="hs-identifier hs-type">ContinueWith</span></a></span><span> </span><span id="local-6989586621681115954"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681115954"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ContinueWith&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681115954"><span class="hs-identifier hs-var">w</span></a></span></span><span>
</span><span id="line-2283"></span><span>
</span><span id="line-2284"></span><span id="local-6989586621681117462"><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-type">continueWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681117462"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117462"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-2285"></span><span id="continueWith"><span class="annot"><span class="annottext">continueWith :: forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var hs-var">continueWith</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StopOrContinue a -&gt; TcS (StopOrContinue a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(StopOrContinue a -&gt; TcS (StopOrContinue a))
-&gt; (a -&gt; StopOrContinue a) -&gt; a -&gt; TcS (StopOrContinue a)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; StopOrContinue a
forall a. a -&gt; StopOrContinue a
</span><a href="GHC.Tc.Solver.Canonical.html#ContinueWith"><span class="hs-identifier hs-var">ContinueWith</span></a></span><span>
</span><span id="line-2286"></span><span>
</span><span id="line-2287"></span><span id="local-6989586621681117448"><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-type">stopWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117448"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-2288"></span><span id="stopWith"><span class="annot"><span class="annottext">stopWith :: forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var hs-var">stopWith</span></a></span></span><span> </span><span id="local-6989586621681115951"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115951"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681115950"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681115950"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StopOrContinue a -&gt; TcS (StopOrContinue a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc -&gt; StopOrContinue a
forall a. CtEvidence -&gt; SDoc -&gt; StopOrContinue a
</span><a href="GHC.Tc.Solver.Canonical.html#Stop"><span class="hs-identifier hs-var">Stop</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115951"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681115950"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2289"></span><span>
</span><span id="line-2290"></span><span id="local-6989586621681117463"><span id="local-6989586621681117464"><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#andWhenContinue"><span class="hs-identifier hs-type">andWhenContinue</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117464"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2291"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681117464"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117463"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2292"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681117463"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-2293"></span><span id="andWhenContinue"><span class="annot"><span class="annottext">andWhenContinue :: forall a b.
TcS (StopOrContinue a)
-&gt; (a -&gt; TcS (StopOrContinue b)) -&gt; TcS (StopOrContinue b)
</span><a href="GHC.Tc.Solver.Canonical.html#andWhenContinue"><span class="hs-identifier hs-var hs-var">andWhenContinue</span></a></span></span><span> </span><span id="local-6989586621681115947"><span class="annot"><span class="annottext">TcS (StopOrContinue a)
</span><a href="#local-6989586621681115947"><span class="hs-identifier hs-var">tcs1</span></a></span></span><span> </span><span id="local-6989586621681115946"><span class="annot"><span class="annottext">a -&gt; TcS (StopOrContinue b)
</span><a href="#local-6989586621681115946"><span class="hs-identifier hs-var">tcs2</span></a></span></span><span>
</span><span id="line-2294"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115945"><span class="annot"><span class="annottext">StopOrContinue a
</span><a href="#local-6989586621681115945"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS (StopOrContinue a)
</span><a href="#local-6989586621681115947"><span class="hs-identifier hs-var">tcs1</span></a></span><span>
</span><span id="line-2295"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">StopOrContinue a
</span><a href="#local-6989586621681115945"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2296"></span><span>           </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#Stop"><span class="hs-identifier hs-type">Stop</span></a></span><span> </span><span id="local-6989586621681115944"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115944"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span id="local-6989586621681115943"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681115943"><span class="hs-identifier hs-var">s</span></a></span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">StopOrContinue b -&gt; TcS (StopOrContinue b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc -&gt; StopOrContinue b
forall a. CtEvidence -&gt; SDoc -&gt; StopOrContinue a
</span><a href="GHC.Tc.Solver.Canonical.html#Stop"><span class="hs-identifier hs-var">Stop</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115944"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681115943"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2297"></span><span>           </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#ContinueWith"><span class="hs-identifier hs-type">ContinueWith</span></a></span><span> </span><span id="local-6989586621681115942"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681115942"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a -&gt; TcS (StopOrContinue b)
</span><a href="#local-6989586621681115946"><span class="hs-identifier hs-var">tcs2</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681115942"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2298"></span><span class="hs-keyword">infixr</span><span> </span><span class="hs-number">0</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#andWhenContinue"><span class="hs-operator hs-type">`andWhenContinue`</span></a></span><span>    </span><span class="hs-comment">-- allow chaining with ($)</span><span>
</span><span id="line-2299"></span><span>
</span><span id="line-2300"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-type">rewriteEvidence</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>   </span><span class="hs-comment">-- old evidence</span><span>
</span><span id="line-2301"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span>   </span><span class="hs-comment">-- new predicate</span><span>
</span><span id="line-2302"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span>   </span><span class="hs-comment">-- Of type :: new predicate ~ &lt;type of old evidence&gt;</span><span>
</span><span id="line-2303"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#StopOrContinue"><span class="hs-identifier hs-type">StopOrContinue</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2304"></span><span class="hs-comment">-- Returns Just new_ev iff either (i)  'co' is reflexivity</span><span>
</span><span id="line-2305"></span><span class="hs-comment">--                             or (ii) 'co' is not reflexivity, and 'new_pred' not cached</span><span>
</span><span id="line-2306"></span><span class="hs-comment">-- In either case, there is nothing new to do with new_ev</span><span>
</span><span id="line-2307"></span><span class="hs-comment">{-
     rewriteEvidence old_ev new_pred co
Main purpose: create new evidence for new_pred;
              unless new_pred is cached already
* Returns a new_ev : new_pred, with same wanted/given/derived flag as old_ev
* If old_ev was wanted, create a binding for old_ev, in terms of new_ev
* If old_ev was given, AND not cached, create a binding for new_ev, in terms of old_ev
* Returns Nothing if new_ev is already cached

        Old evidence    New predicate is               Return new evidence
        flavour                                        of same flavor
        -------------------------------------------------------------------
        Wanted          Already solved or in inert     Nothing
        or Derived      Not                            Just new_evidence

        Given           Already in inert               Nothing
                        Not                            Just new_evidence

Note [Rewriting with Refl]
~~~~~~~~~~~~~~~~~~~~~~~~~~
If the coercion is just reflexivity then you may re-use the same
variable.  But be careful!  Although the coercion is Refl, new_pred
may reflect the result of unification alpha := ty, so new_pred might
not _look_ the same as old_pred, and it's vital to proceed from now on
using new_pred.

qThe flattener preserves type synonyms, so they should appear in new_pred
as well as in old_pred; that is important for good error messages.
 -}</span><span>
</span><span id="line-2336"></span><span>
</span><span id="line-2337"></span><span>
</span><span id="line-2338"></span><span id="rewriteEvidence"><span class="annot"><span class="annottext">rewriteEvidence :: CtEvidence
-&gt; TcType -&gt; TcCoercion -&gt; TcS (StopOrContinue CtEvidence)
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-var hs-var">rewriteEvidence</span></a></span></span><span> </span><span id="local-6989586621681115941"><span class="annot"><span class="annottext">old_ev :: CtEvidence
</span><a href="#local-6989586621681115941"><span class="hs-identifier hs-var">old_ev</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtDerived"><span class="hs-identifier hs-type">CtDerived</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681115940"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115940"><span class="hs-identifier hs-var">new_pred</span></a></span></span><span> </span><span id="local-6989586621681115939"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115939"><span class="hs-identifier hs-var">_co</span></a></span></span><span>
</span><span id="line-2339"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- If derived, don't even look at the coercion.</span><span>
</span><span id="line-2340"></span><span>    </span><span class="hs-comment">-- This is very important, DO NOT re-order the equations for</span><span>
</span><span id="line-2341"></span><span>    </span><span class="hs-comment">-- rewriteEvidence to put the isTcReflCo test first!</span><span>
</span><span id="line-2342"></span><span>    </span><span class="hs-comment">-- Why?  Because for *Derived* constraints, c, the coercion, which</span><span>
</span><span id="line-2343"></span><span>    </span><span class="hs-comment">-- was produced by flattening, may contain suspended calls to</span><span>
</span><span id="line-2344"></span><span>    </span><span class="hs-comment">-- (ctEvExpr c), which fails for Derived constraints.</span><span>
</span><span id="line-2345"></span><span>    </span><span class="hs-comment">-- (Getting this wrong caused #7384.)</span><span>
</span><span id="line-2346"></span><span>    </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcS (StopOrContinue CtEvidence)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115941"><span class="hs-identifier hs-var">old_ev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115940"><span class="hs-identifier hs-var">new_pred</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2347"></span><span>
</span><span id="line-2348"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-var">rewriteEvidence</span></a></span><span> </span><span id="local-6989586621681115937"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115937"><span class="hs-identifier hs-var">old_ev</span></a></span></span><span> </span><span id="local-6989586621681115936"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115936"><span class="hs-identifier hs-var">new_pred</span></a></span></span><span> </span><span id="local-6989586621681115935"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115935"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-2349"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#isTcReflCo"><span class="hs-identifier hs-var">isTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115935"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-comment">-- See Note [Rewriting with Refl]</span><span>
</span><span id="line-2350"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcS (StopOrContinue CtEvidence)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115937"><span class="hs-identifier hs-var">old_ev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115936"><span class="hs-identifier hs-var">new_pred</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2351"></span><span>
</span><span id="line-2352"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-var">rewriteEvidence</span></a></span><span> </span><span id="local-6989586621681115934"><span class="annot"><span class="annottext">ev :: CtEvidence
</span><a href="#local-6989586621681115934"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtGiven"><span class="hs-identifier hs-type">CtGiven</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_evar :: CtEvidence -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctev_evar"><span class="hs-identifier hs-var">ctev_evar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115933"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115933"><span class="hs-identifier hs-var">old_evar</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115932"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115932"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681115931"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115931"><span class="hs-identifier hs-var">new_pred</span></a></span></span><span> </span><span id="local-6989586621681115930"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115930"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-2353"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115929"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115929"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (TcType, EvTerm) -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newGivenEvVar"><span class="hs-identifier hs-var">newGivenEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115932"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115931"><span class="hs-identifier hs-var">new_pred</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681115928"><span class="hs-identifier hs-var">new_tm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2354"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcS (StopOrContinue CtEvidence)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115929"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2355"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2356"></span><span>    </span><span class="hs-comment">-- mkEvCast optimises ReflCo</span><span>
</span><span id="line-2357"></span><span>    </span><span id="local-6989586621681115928"><span class="annot"><span class="annottext">new_tm :: EvTerm
</span><a href="#local-6989586621681115928"><span class="hs-identifier hs-var hs-var">new_tm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvExpr -&gt; TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#mkEvCast"><span class="hs-identifier hs-var">mkEvCast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; EvExpr
</span><a href="GHC.Tc.Types.Evidence.html#evId"><span class="hs-identifier hs-var">evId</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115933"><span class="hs-identifier hs-var">old_evar</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Role -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#tcDowngradeRole"><span class="hs-identifier hs-var">tcDowngradeRole</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span>
</span><span id="line-2358"></span><span>                                                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Role
</span><a href="GHC.Tc.Types.Constraint.html#ctEvRole"><span class="hs-identifier hs-var">ctEvRole</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115934"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2359"></span><span>                                                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115930"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2360"></span><span>
</span><span id="line-2361"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#rewriteEvidence"><span class="hs-identifier hs-var">rewriteEvidence</span></a></span><span> </span><span id="local-6989586621681115926"><span class="annot"><span class="annottext">ev :: CtEvidence
</span><a href="#local-6989586621681115926"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115925"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681115925"><span class="hs-identifier hs-var">dest</span></a></span></span><span>
</span><span id="line-2362"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_nosh :: CtEvidence -&gt; ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#ctev_nosh"><span class="hs-identifier hs-var">ctev_nosh</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115923"><span class="annot"><span class="annottext">ShadowInfo
</span><a href="#local-6989586621681115923"><span class="hs-identifier hs-var">si</span></a></span></span><span>
</span><span id="line-2363"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115922"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115922"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681115921"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115921"><span class="hs-identifier hs-var">new_pred</span></a></span></span><span> </span><span id="local-6989586621681115920"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115920"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-2364"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115919"><span class="annot"><span class="annottext">MaybeNew
</span><a href="#local-6989586621681115919"><span class="hs-identifier hs-var">mb_new_ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ShadowInfo -&gt; CtLoc -&gt; TcType -&gt; TcS MaybeNew
</span><a href="GHC.Tc.Solver.Monad.html#newWanted_SI"><span class="hs-identifier hs-var">newWanted_SI</span></a></span><span> </span><span class="annot"><span class="annottext">ShadowInfo
</span><a href="#local-6989586621681115923"><span class="hs-identifier hs-var">si</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115922"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115921"><span class="hs-identifier hs-var">new_pred</span></a></span><span>
</span><span id="line-2365"></span><span>               </span><span class="hs-comment">-- The &quot;_SI&quot; variant ensures that we make a new Wanted</span><span>
</span><span id="line-2366"></span><span>               </span><span class="hs-comment">-- with the same shadow-info as the existing one</span><span>
</span><span id="line-2367"></span><span>               </span><span class="hs-comment">-- with the same shadow-info as the existing one (#16735)</span><span>
</span><span id="line-2368"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">MASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tcCoercionRole</span><span> </span><span class="hs-identifier">co</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">ctEvRole</span><span> </span><span class="hs-identifier">ev</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-2369"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcEvDest -&gt; EvTerm -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setWantedEvTerm"><span class="hs-identifier hs-var">setWantedEvTerm</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681115925"><span class="hs-identifier hs-var">dest</span></a></span><span>
</span><span id="line-2370"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EvExpr -&gt; TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#mkEvCast"><span class="hs-identifier hs-var">mkEvCast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MaybeNew -&gt; EvExpr
</span><a href="GHC.Tc.Solver.Monad.html#getEvExpr"><span class="hs-identifier hs-var">getEvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">MaybeNew
</span><a href="#local-6989586621681115919"><span class="hs-identifier hs-var">mb_new_ev</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2371"></span><span>                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Role -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#tcDowngradeRole"><span class="hs-identifier hs-var">tcDowngradeRole</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Role
</span><a href="GHC.Tc.Types.Constraint.html#ctEvRole"><span class="hs-identifier hs-var">ctEvRole</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115926"><span class="hs-identifier hs-var">ev</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115920"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2372"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MaybeNew
</span><a href="#local-6989586621681115919"><span class="hs-identifier hs-var">mb_new_ev</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2373"></span><span>            </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#Fresh"><span class="hs-identifier hs-type">Fresh</span></a></span><span>  </span><span id="local-6989586621681115914"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115914"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcS (StopOrContinue CtEvidence)
forall a. a -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#continueWith"><span class="hs-identifier hs-var">continueWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115914"><span class="hs-identifier hs-var">new_ev</span></a></span><span>
</span><span id="line-2374"></span><span>            </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#Cached"><span class="hs-identifier hs-type">Cached</span></a></span><span> </span><span class="annot"><span class="annottext">EvExpr
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; String -&gt; TcS (StopOrContinue CtEvidence)
forall a. CtEvidence -&gt; String -&gt; TcS (StopOrContinue a)
</span><a href="GHC.Tc.Solver.Canonical.html#stopWith"><span class="hs-identifier hs-var">stopWith</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115926"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cached wanted&quot;</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2375"></span><span>
</span><span id="line-2376"></span><span>
</span><span id="line-2377"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-type">rewriteEqEvidence</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>         </span><span class="hs-comment">-- Old evidence :: olhs ~ orhs (not swapped)</span><span>
</span><span id="line-2378"></span><span>                                        </span><span class="hs-comment">--              or orhs ~ olhs (swapped)</span><span>
</span><span id="line-2379"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-2380"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>   </span><span class="hs-comment">-- New predicate  nlhs ~ nrhs</span><span>
</span><span id="line-2381"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span>         </span><span class="hs-comment">-- lhs_co, of type :: nlhs ~ olhs</span><span>
</span><span id="line-2382"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span>         </span><span class="hs-comment">-- rhs_co, of type :: nrhs ~ orhs</span><span>
</span><span id="line-2383"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>     </span><span class="hs-comment">-- Of type nlhs ~ nrhs</span><span>
</span><span id="line-2384"></span><span class="hs-comment">-- For (rewriteEqEvidence (Given g olhs orhs) False nlhs nrhs lhs_co rhs_co)</span><span>
</span><span id="line-2385"></span><span class="hs-comment">-- we generate</span><span>
</span><span id="line-2386"></span><span class="hs-comment">-- If not swapped</span><span>
</span><span id="line-2387"></span><span class="hs-comment">--      g1 : nlhs ~ nrhs = lhs_co ; g ; sym rhs_co</span><span>
</span><span id="line-2388"></span><span class="hs-comment">-- If 'swapped'</span><span>
</span><span id="line-2389"></span><span class="hs-comment">--      g1 : nlhs ~ nrhs = lhs_co ; Sym g ; sym rhs_co</span><span>
</span><span id="line-2390"></span><span class="hs-comment">--</span><span>
</span><span id="line-2391"></span><span class="hs-comment">-- For (Wanted w) we do the dual thing.</span><span>
</span><span id="line-2392"></span><span class="hs-comment">-- New  w1 : nlhs ~ nrhs</span><span>
</span><span id="line-2393"></span><span class="hs-comment">-- If not swapped</span><span>
</span><span id="line-2394"></span><span class="hs-comment">--      w : olhs ~ orhs = sym lhs_co ; w1 ; rhs_co</span><span>
</span><span id="line-2395"></span><span class="hs-comment">-- If swapped</span><span>
</span><span id="line-2396"></span><span class="hs-comment">--      w : orhs ~ olhs = sym rhs_co ; sym w1 ; lhs_co</span><span>
</span><span id="line-2397"></span><span class="hs-comment">--</span><span>
</span><span id="line-2398"></span><span class="hs-comment">-- It's all a form of rewwriteEvidence, specialised for equalities</span><span>
</span><span id="line-2399"></span><span id="rewriteEqEvidence"><span class="annot"><span class="annottext">rewriteEqEvidence :: CtEvidence
-&gt; SwapFlag
-&gt; TcType
-&gt; TcType
-&gt; TcCoercion
-&gt; TcCoercion
-&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Canonical.html#rewriteEqEvidence"><span class="hs-identifier hs-var hs-var">rewriteEqEvidence</span></a></span></span><span> </span><span id="local-6989586621681115912"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span></span><span> </span><span id="local-6989586621681115911"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115911"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681115910"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115910"><span class="hs-identifier hs-var">nlhs</span></a></span></span><span> </span><span id="local-6989586621681115909"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115909"><span class="hs-identifier hs-var">nrhs</span></a></span></span><span> </span><span id="local-6989586621681115908"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115908"><span class="hs-identifier hs-var">lhs_co</span></a></span></span><span> </span><span id="local-6989586621681115907"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115907"><span class="hs-identifier hs-var">rhs_co</span></a></span></span><span>
</span><span id="line-2400"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtDerived"><span class="hs-identifier hs-type">CtDerived</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span>  </span><span class="hs-comment">-- Don't force the evidence for a Derived</span><span>
</span><span id="line-2401"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcS CtEvidence
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115906"><span class="hs-identifier hs-var">new_pred</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2402"></span><span>
</span><span id="line-2403"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115911"><span class="hs-identifier hs-var">swapped</span></a></span><span>
</span><span id="line-2404"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#isTcReflCo"><span class="hs-identifier hs-var">isTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115908"><span class="hs-identifier hs-var">lhs_co</span></a></span><span>      </span><span class="hs-comment">-- See Note [Rewriting with Refl]</span><span>
</span><span id="line-2405"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#isTcReflCo"><span class="hs-identifier hs-var">isTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115907"><span class="hs-identifier hs-var">rhs_co</span></a></span><span>
</span><span id="line-2406"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcS CtEvidence
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: TcType
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115906"><span class="hs-identifier hs-var">new_pred</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2407"></span><span>
</span><span id="line-2408"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtGiven"><span class="hs-identifier hs-type">CtGiven</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_evar :: CtEvidence -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctev_evar"><span class="hs-identifier hs-var">ctev_evar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115905"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115905"><span class="hs-identifier hs-var">old_evar</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span>
</span><span id="line-2409"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681115904"><span class="annot"><span class="annottext">new_tm :: EvTerm
</span><a href="#local-6989586621681115904"><span class="hs-identifier hs-var hs-var">new_tm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115908"><span class="hs-identifier hs-var">lhs_co</span></a></span><span>
</span><span id="line-2410"></span><span>                                  </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcTransCo"><span class="hs-operator hs-var">`mkTcTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#maybeSym"><span class="hs-identifier hs-var">maybeSym</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115911"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcCoVarCo"><span class="hs-identifier hs-var">mkTcCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115905"><span class="hs-identifier hs-var">old_evar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2411"></span><span>                                  </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcTransCo"><span class="hs-operator hs-var">`mkTcTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115907"><span class="hs-identifier hs-var">rhs_co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2412"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; (TcType, EvTerm) -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newGivenEvVar"><span class="hs-identifier hs-var">newGivenEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115903"><span class="hs-identifier hs-var">loc'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115906"><span class="hs-identifier hs-var">new_pred</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681115904"><span class="hs-identifier hs-var">new_tm</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2413"></span><span>
</span><span id="line-2414"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115902"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681115902"><span class="hs-identifier hs-var">dest</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_nosh :: CtEvidence -&gt; ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#ctev_nosh"><span class="hs-identifier hs-var">ctev_nosh</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681115901"><span class="annot"><span class="annottext">ShadowInfo
</span><a href="#local-6989586621681115901"><span class="hs-identifier hs-var">si</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span>
</span><span id="line-2415"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681115902"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2416"></span><span>      </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#HoleDest"><span class="hs-identifier hs-type">HoleDest</span></a></span><span> </span><span id="local-6989586621681115899"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681115899"><span class="hs-identifier hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-2417"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681115898"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115898"><span class="hs-identifier hs-var">new_ev</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681115897"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115897"><span class="hs-identifier hs-var">hole_co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
-&gt; ShadowInfo
-&gt; CtLoc
-&gt; Role
-&gt; TcType
-&gt; TcType
-&gt; TcS (CtEvidence, TcCoercion)
</span><a href="GHC.Tc.Solver.Monad.html#newWantedEq_SI"><span class="hs-identifier hs-var">newWantedEq_SI</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionHole -&gt; BlockSubstFlag
</span><a href="GHC.Core.TyCo.Rep.html#ch_blocker"><span class="hs-identifier hs-var hs-var">ch_blocker</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681115899"><span class="hs-identifier hs-var">hole</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ShadowInfo
</span><a href="#local-6989586621681115901"><span class="hs-identifier hs-var">si</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115903"><span class="hs-identifier hs-var">loc'</span></a></span><span>
</span><span id="line-2418"></span><span>                                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Role
</span><a href="GHC.Tc.Types.Constraint.html#ctEvRole"><span class="hs-identifier hs-var">ctEvRole</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115910"><span class="hs-identifier hs-var">nlhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115909"><span class="hs-identifier hs-var">nrhs</span></a></span><span>
</span><span id="line-2419"></span><span>                   </span><span class="hs-comment">-- The &quot;_SI&quot; variant ensures that we make a new Wanted</span><span>
</span><span id="line-2420"></span><span>                   </span><span class="hs-comment">-- with the same shadow-info as the existing one (#16735)</span><span>
</span><span id="line-2421"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681115894"><span class="annot"><span class="annottext">co :: TcCoercion
</span><a href="#local-6989586621681115894"><span class="hs-identifier hs-var hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SwapFlag -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#maybeSym"><span class="hs-identifier hs-var">maybeSym</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681115911"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">(TcCoercion -&gt; TcCoercion) -&gt; TcCoercion -&gt; TcCoercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2422"></span><span>                      </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115908"><span class="hs-identifier hs-var">lhs_co</span></a></span><span>
</span><span id="line-2423"></span><span>                      </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115897"><span class="hs-identifier hs-var">hole_co</span></a></span><span>
</span><span id="line-2424"></span><span>                      </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115907"><span class="hs-identifier hs-var">rhs_co</span></a></span><span>
</span><span id="line-2425"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcEvDest -&gt; TcCoercion -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setWantedEq"><span class="hs-identifier hs-var">setWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681115902"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115894"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-2426"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rewriteEqEvidence&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CtEvidence -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115910"><span class="hs-identifier hs-var">nlhs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115909"><span class="hs-identifier hs-var">nrhs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115894"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2427"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcS CtEvidence
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115898"><span class="hs-identifier hs-var">new_ev</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2428"></span><span>
</span><span id="line-2429"></span><span>      </span><span class="annot"><span class="annottext">TcEvDest
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcS CtEvidence
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rewriteEqEvidence&quot;</span></span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &lt;= 810
</span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>
</span><span id="line-2433"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">panic</span><span> </span><span class="hs-string">&quot;rewriteEvidence&quot;</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2436"></span><span>    </span><span id="local-6989586621681115906"><span class="annot"><span class="annottext">new_pred :: TcType
</span><a href="#local-6989586621681115906"><span class="hs-identifier hs-var hs-var">new_pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Tc.Types.Constraint.html#mkTcEqPredLikeEv"><span class="hs-identifier hs-var">mkTcEqPredLikeEv</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115910"><span class="hs-identifier hs-var">nlhs</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115909"><span class="hs-identifier hs-var">nrhs</span></a></span><span>
</span><span id="line-2437"></span><span>
</span><span id="line-2438"></span><span>      </span><span class="hs-comment">-- equality is like a type class. Bumping the depth is necessary because</span><span>
</span><span id="line-2439"></span><span>      </span><span class="hs-comment">-- of recursive newtypes, where &quot;reducing&quot; a newtype can actually make</span><span>
</span><span id="line-2440"></span><span>      </span><span class="hs-comment">-- it bigger. See Note [Newtypes can blow the stack].</span><span>
</span><span id="line-2441"></span><span>    </span><span id="local-6989586621681115891"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681115891"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctEvLoc"><span class="hs-identifier hs-var">ctEvLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681115912"><span class="hs-identifier hs-var">old_ev</span></a></span><span>
</span><span id="line-2442"></span><span>    </span><span id="local-6989586621681115903"><span class="annot"><span class="annottext">loc' :: CtLoc
</span><a href="#local-6989586621681115903"><span class="hs-identifier hs-var hs-var">loc'</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#bumpCtLocDepth"><span class="hs-identifier hs-var">bumpCtLocDepth</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115891"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-2443"></span><span>
</span><span id="line-2444"></span><span class="hs-comment">{- Note [unifyWanted and unifyDerived]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When decomposing equalities we often create new wanted constraints for
(s ~ t).  But what if s=t?  Then it'd be faster to return Refl right away.
Similar remarks apply for Derived.

Rather than making an equality test (which traverses the structure of the
type, perhaps fruitlessly), unifyWanted traverses the common structure, and
bales out when it finds a difference by creating a new Wanted constraint.
But where it succeeds in finding common structure, it just builds a coercion
to reflect it.
-}</span><span>
</span><span id="line-2456"></span><span>
</span><span id="line-2457"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-type">unifyWanted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtLoc"><span class="hs-identifier hs-type">CtLoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span>
</span><span id="line-2458"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-2459"></span><span class="hs-comment">-- Return coercion witnessing the equality of the two types,</span><span>
</span><span id="line-2460"></span><span class="hs-comment">-- emitting new work equalities where necessary to achieve that</span><span>
</span><span id="line-2461"></span><span class="hs-comment">-- Very good short-cut when the two types are equal, or nearly so</span><span>
</span><span id="line-2462"></span><span class="hs-comment">-- See Note [unifyWanted and unifyDerived]</span><span>
</span><span id="line-2463"></span><span class="hs-comment">-- The returned coercion's role matches the input parameter</span><span>
</span><span id="line-2464"></span><span id="unifyWanted"><span class="annot"><span class="annottext">unifyWanted :: CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var hs-var">unifyWanted</span></a></span></span><span> </span><span id="local-6989586621681115889"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115889"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Phantom"><span class="hs-identifier hs-var">Phantom</span></a></span><span> </span><span id="local-6989586621681115888"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115888"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115887"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115887"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-2465"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115886"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115886"><span class="hs-identifier hs-var">kind_co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115889"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115888"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115887"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2466"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcS TcCoercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcCoercion -&gt; TcType -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkPhantomCo"><span class="hs-identifier hs-var">mkPhantomCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115886"><span class="hs-identifier hs-var">kind_co</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115888"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115887"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2467"></span><span>
</span><span id="line-2468"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span id="local-6989586621681115884"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115884"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681115883"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span></span><span> </span><span id="local-6989586621681115882"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115882"><span class="hs-identifier hs-var">orig_ty1</span></a></span></span><span> </span><span id="local-6989586621681115881"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115881"><span class="hs-identifier hs-var">orig_ty2</span></a></span></span><span>
</span><span id="line-2469"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115882"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115881"><span class="hs-identifier hs-var">orig_ty2</span></a></span><span>
</span><span id="line-2470"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2471"></span><span>    </span><span id="local-6989586621681115880"><span class="annot"><span class="annottext">go :: TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115880"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681115867"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115867"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115866"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115866"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115865"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115865"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115867"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115865"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115866"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2472"></span><span>    </span><span class="annot"><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115864"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115864"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115863"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115863"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115862"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115862"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115863"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115864"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115862"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-2473"></span><span>
</span><span id="line-2474"></span><span>    </span><span class="annot"><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681115861"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115861"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span id="local-6989586621681115860"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115860"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621681115859"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115859"><span class="hs-identifier hs-var">t1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681115858"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115858"><span class="hs-identifier hs-var">w2</span></a></span></span><span> </span><span id="local-6989586621681115857"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115857"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span id="local-6989586621681115856"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115856"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2475"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115855"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115855"><span class="hs-identifier hs-var">co_s</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115884"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115860"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115857"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-2476"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681115854"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115854"><span class="hs-identifier hs-var">co_t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115884"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115859"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115856"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-2477"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681115853"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115853"><span class="hs-identifier hs-var">co_w</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115884"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115861"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115858"><span class="hs-identifier hs-var">w2</span></a></span><span>
</span><span id="line-2478"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcS TcCoercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcCoercion -&gt; TcCoercion -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkFunCo"><span class="hs-identifier hs-var">mkFunCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115853"><span class="hs-identifier hs-var">co_w</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115855"><span class="hs-identifier hs-var">co_s</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115854"><span class="hs-identifier hs-var">co_t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2479"></span><span>    </span><span class="annot"><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681115851"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115851"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621681115850"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115850"><span class="hs-identifier hs-var">tys1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681115849"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115849"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621681115848"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115848"><span class="hs-identifier hs-var">tys2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2480"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115851"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115849"><span class="hs-identifier hs-var">tc2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115850"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType] -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-operator hs-var">`equalLength`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115848"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-2481"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isInjectiveTyCon"><span class="hs-identifier hs-var">isInjectiveTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115851"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="hs-comment">-- don't look under newtypes at Rep equality</span><span>
</span><span id="line-2482"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115847"><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681115847"><span class="hs-identifier hs-var">cos</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion)
-&gt; [Role] -&gt; [TcType] -&gt; [TcType] -&gt; TcS [TcCoercion]
forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; b -&gt; c -&gt; m d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; m [d]
</span><a href="GHC.Utils.Monad.html#zipWith3M"><span class="hs-identifier hs-var">zipWith3M</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#unifyWanted"><span class="hs-identifier hs-var">unifyWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115884"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2483"></span><span>                              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [Role]
</span><a href="GHC.Core.Coercion.html#tyConRolesX"><span class="hs-identifier hs-var">tyConRolesX</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115851"><span class="hs-identifier hs-var">tc1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115850"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115848"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-2484"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcS TcCoercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Role -&gt; TyCon -&gt; [TcCoercion] -&gt; TcCoercion
Role -&gt; TyCon -&gt; [TcCoercion] -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkTyConAppCo"><span class="hs-identifier hs-var">mkTyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115851"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcCoercion]
</span><a href="#local-6989586621681115847"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2485"></span><span>
</span><span id="line-2486"></span><span>    </span><span class="annot"><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115845"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681115845"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681115844"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115844"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681115843"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115843"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-2487"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115842"><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115842"><span class="hs-identifier hs-var">mb_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS (Maybe TcType)
</span><a href="GHC.Tc.Solver.Monad.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-var">isFilledMetaTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115844"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2488"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115842"><span class="hs-identifier hs-var">mb_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2489"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115840"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115840"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115840"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115843"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2490"></span><span>                </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115839"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115845"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115843"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-2491"></span><span>    </span><span class="annot"><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115838"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115838"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115837"><span class="annot"><span class="annottext">ty2 :: TcType
</span><a href="#local-6989586621681115837"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681115836"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115836"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2492"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115835"><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115835"><span class="hs-identifier hs-var">mb_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS (Maybe TcType)
</span><a href="GHC.Tc.Solver.Monad.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-var">isFilledMetaTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115836"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2493"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115835"><span class="hs-identifier hs-var">mb_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2494"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115834"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115834"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115838"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115834"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-2495"></span><span>                </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115839"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115838"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115837"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2496"></span><span>
</span><span id="line-2497"></span><span>    </span><span class="annot"><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115833"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681115833"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2498"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcS TcCoercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115833"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- we just don't care about coercions!</span><span>
</span><span id="line-2499"></span><span>
</span><span id="line-2500"></span><span>    </span><span class="annot"><a href="#local-6989586621681115880"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115831"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115831"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115830"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115830"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115839"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115831"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115830"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2501"></span><span>
</span><span id="line-2502"></span><span>    </span><span id="local-6989586621681115839"><span class="annot"><span class="annottext">bale_out :: TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="#local-6989586621681115839"><span class="hs-identifier hs-var hs-var">bale_out</span></a></span></span><span> </span><span id="local-6989586621681115827"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115827"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115826"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115826"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-2503"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115827"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-operator hs-var">`tcEqType`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115826"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcS TcCoercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcReflCo"><span class="hs-identifier hs-var">mkTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115827"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2504"></span><span>        </span><span class="hs-comment">-- Check for equality; e.g. a ~ a, or (m a) ~ (m a)</span><span>
</span><span id="line-2505"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS TcCoercion
</span><a href="GHC.Tc.Solver.Monad.html#emitNewWantedEq"><span class="hs-identifier hs-var">emitNewWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115884"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115883"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115882"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115881"><span class="hs-identifier hs-var">orig_ty2</span></a></span><span>
</span><span id="line-2506"></span><span>
</span><span id="line-2507"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#unifyDeriveds"><span class="hs-identifier hs-type">unifyDeriveds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtLoc"><span class="hs-identifier hs-type">CtLoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2508"></span><span class="hs-comment">-- See Note [unifyWanted and unifyDerived]</span><span>
</span><span id="line-2509"></span><span id="unifyDeriveds"><span class="annot"><span class="annottext">unifyDeriveds :: CtLoc -&gt; [Role] -&gt; [TcType] -&gt; [TcType] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unifyDeriveds"><span class="hs-identifier hs-var hs-var">unifyDeriveds</span></a></span></span><span> </span><span id="local-6989586621681115824"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115824"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681115823"><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681115823"><span class="hs-identifier hs-var">roles</span></a></span></span><span> </span><span id="local-6989586621681115822"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115822"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621681115821"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115821"><span class="hs-identifier hs-var">tys2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Role -&gt; TcType -&gt; TcType -&gt; TcS ())
-&gt; [Role] -&gt; [TcType] -&gt; [TcType] -&gt; TcS ()
forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; b -&gt; c -&gt; m d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; m ()
</span><a href="GHC.Utils.Monad.html#zipWith3M_"><span class="hs-identifier hs-var">zipWith3M_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-var">unify_derived</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115824"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Role]
</span><a href="#local-6989586621681115823"><span class="hs-identifier hs-var">roles</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115822"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115821"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-2510"></span><span>
</span><span id="line-2511"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#unifyDerived"><span class="hs-identifier hs-type">unifyDerived</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtLoc"><span class="hs-identifier hs-type">CtLoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2512"></span><span class="hs-comment">-- See Note [unifyWanted and unifyDerived]</span><span>
</span><span id="line-2513"></span><span id="unifyDerived"><span class="annot"><span class="annottext">unifyDerived :: CtLoc -&gt; Role -&gt; Pair TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unifyDerived"><span class="hs-identifier hs-var hs-var">unifyDerived</span></a></span></span><span> </span><span id="local-6989586621681115818"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115818"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681115817"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115817"><span class="hs-keyword hs-var">role</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621681115816"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115816"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115815"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115815"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-var">unify_derived</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115818"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115817"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115816"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115815"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2514"></span><span>
</span><span id="line-2515"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-type">unify_derived</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtLoc"><span class="hs-identifier hs-type">CtLoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2516"></span><span class="hs-comment">-- Create new Derived and put it in the work list</span><span>
</span><span id="line-2517"></span><span class="hs-comment">-- Should do nothing if the two types are equal</span><span>
</span><span id="line-2518"></span><span class="hs-comment">-- See Note [unifyWanted and unifyDerived]</span><span>
</span><span id="line-2519"></span><span id="unify_derived"><span class="annot"><span class="annottext">unify_derived :: CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-var hs-var">unify_derived</span></a></span></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Phantom"><span class="hs-identifier hs-var">Phantom</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>        </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcS ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2520"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-var">unify_derived</span></a></span><span> </span><span id="local-6989586621681115814"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115814"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681115813"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115813"><span class="hs-keyword hs-var">role</span></a></span></span><span>    </span><span id="local-6989586621681115812"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115812"><span class="hs-identifier hs-var">orig_ty1</span></a></span></span><span> </span><span id="local-6989586621681115811"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115811"><span class="hs-identifier hs-var">orig_ty2</span></a></span></span><span>
</span><span id="line-2521"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115812"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115811"><span class="hs-identifier hs-var">orig_ty2</span></a></span><span>
</span><span id="line-2522"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2523"></span><span>    </span><span id="local-6989586621681115810"><span class="annot"><span class="annottext">go :: TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115810"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681115804"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115804"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115803"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115803"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115802"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115802"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115804"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115802"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115803"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2524"></span><span>    </span><span class="annot"><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115801"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115801"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115800"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115800"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115799"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115799"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115800"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115801"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115799"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-2525"></span><span>
</span><span id="line-2526"></span><span>    </span><span class="annot"><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681115798"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115798"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span id="local-6989586621681115797"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115797"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621681115796"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115796"><span class="hs-identifier hs-var">t1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681115795"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115795"><span class="hs-identifier hs-var">w2</span></a></span></span><span> </span><span id="local-6989586621681115794"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115794"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span id="local-6989586621681115793"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115793"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2527"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-var">unify_derived</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115814"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115813"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115797"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115794"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-2528"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-var">unify_derived</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115814"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115813"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115796"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115793"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-2529"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unify_derived"><span class="hs-identifier hs-var">unify_derived</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115814"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115798"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115795"><span class="hs-identifier hs-var">w2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2530"></span><span>    </span><span class="annot"><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681115792"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115792"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621681115791"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115791"><span class="hs-identifier hs-var">tys1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681115790"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115790"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621681115789"><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115789"><span class="hs-identifier hs-var">tys2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2531"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115792"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115790"><span class="hs-identifier hs-var">tc2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115791"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType] -&gt; [TcType] -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-operator hs-var">`equalLength`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115789"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-2532"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isInjectiveTyCon"><span class="hs-identifier hs-var">isInjectiveTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115792"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115813"><span class="hs-keyword hs-var">role</span></a></span><span>
</span><span id="line-2533"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [Role] -&gt; [TcType] -&gt; [TcType] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#unifyDeriveds"><span class="hs-identifier hs-var">unifyDeriveds</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115814"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [Role]
</span><a href="GHC.Core.Coercion.html#tyConRolesX"><span class="hs-identifier hs-var">tyConRolesX</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115813"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681115792"><span class="hs-identifier hs-var">tc1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115791"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[TcType]
</span><a href="#local-6989586621681115789"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-2534"></span><span>    </span><span class="annot"><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115788"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681115788"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681115787"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115787"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681115786"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115786"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-2535"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115785"><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115785"><span class="hs-identifier hs-var">mb_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS (Maybe TcType)
</span><a href="GHC.Tc.Solver.Monad.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-var">isFilledMetaTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115787"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2536"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115785"><span class="hs-identifier hs-var">mb_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2537"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115784"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115784"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115784"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115786"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2538"></span><span>                </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115783"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115788"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115786"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2539"></span><span>    </span><span class="annot"><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115782"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115782"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115781"><span class="annot"><span class="annottext">ty2 :: TcType
</span><a href="#local-6989586621681115781"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681115780"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115780"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2540"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681115779"><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115779"><span class="hs-identifier hs-var">mb_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS (Maybe TcType)
</span><a href="GHC.Tc.Solver.Monad.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-var">isFilledMetaTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681115780"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2541"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681115779"><span class="hs-identifier hs-var">mb_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2542"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681115778"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115778"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115782"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115778"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-2543"></span><span>                </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115783"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115782"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115781"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2544"></span><span>    </span><span class="annot"><a href="#local-6989586621681115810"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681115777"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115777"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115776"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115776"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115783"><span class="hs-identifier hs-var">bale_out</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115777"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115776"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2545"></span><span>
</span><span id="line-2546"></span><span>    </span><span id="local-6989586621681115783"><span class="annot"><span class="annottext">bale_out :: TcType -&gt; TcType -&gt; TcS ()
</span><a href="#local-6989586621681115783"><span class="hs-identifier hs-var hs-var">bale_out</span></a></span></span><span> </span><span id="local-6989586621681115773"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115773"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681115772"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115772"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-2547"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115773"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-operator hs-var">`tcEqType`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115772"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcS ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2548"></span><span>        </span><span class="hs-comment">-- Check for equality; e.g. a ~ a, or (m a) ~ (m a)</span><span>
</span><span id="line-2549"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#emitNewDerivedEq"><span class="hs-identifier hs-var">emitNewDerivedEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681115814"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681115813"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115812"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681115811"><span class="hs-identifier hs-var">orig_ty2</span></a></span><span>
</span><span id="line-2550"></span><span>
</span><span id="line-2551"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#maybeSym"><span class="hs-identifier hs-type">maybeSym</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span>
</span><span id="line-2552"></span><span id="maybeSym"><span class="annot"><span class="annottext">maybeSym :: SwapFlag -&gt; TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Solver.Canonical.html#maybeSym"><span class="hs-identifier hs-var hs-var">maybeSym</span></a></span></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span>  </span><span id="local-6989586621681115770"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115770"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion -&gt; TcCoercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115770"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-2553"></span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#maybeSym"><span class="hs-identifier hs-var">maybeSym</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span id="local-6989586621681115769"><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115769"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcCoercion
</span><a href="#local-6989586621681115769"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-2554"></span></pre></body></html>